次のコードは.csvファイルに出力する必要があります。
注!まず、MicrosoftスクリプトランタイムDLL(scrrun.dll)への参照を追加してください:VBAウィンドウから
ツール - > References-> MicrosoftスクリプトランタイムDLLに
を確認してくださいここで動作するコード(することができますです)マクロを作成し、その中にコードを配置:
Dim wordsArray, arrayElement
Dim delimiter As String
Dim fileName As String
Dim fso As FileSystemObject
Dim outputFile As textStream
'select all document's content
ActiveDocument.Select
'provide delimiter
delimiter = InputBox("Please enter delimiter to use")
'split the selected content and place it inside the array
wordsArray = Split(Selection.Text, delimiter)
'generate output file name
fileName = "C:\Output.csv"
'create new FileSystem object and open text stream to write to
Set fs = New FileSystemObject
Set outputFile = fs.CreateTextFile(fileName, True) 'note file will be overwritten
'iterate through array and write to the file
For Each arrayElement In wordsArray
'Use the following code to place each word into separate COLUMN
'outputFile.Write (arrayElement) & ","
'Use the following code to place each word into separate ROW
outputFile.WriteLine (arrayElement)
Next
'close output stream
outputFile.Close
あなたは、あなたのニーズに基づいて、それをマッサージすることができます...
は、この情報がお役に立てば幸いです。
すべてのテキストをWord文書または他の場所からコピーしますか?あなたは "単一列"のcsvファイルについて言及していますが、Accessテーブルの説明はマルチカラムのように見えます。 –
MS Accessデータベースを使用する場合、テーブルあたり最大255個のカラムがあります。 )。 –