Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[vba/excel] テキストファイルにデータを書き出す
'------------------------------------------------------------------------------
'テキストファイルにデータを書き出す
'------------------------------------------------------------------------------
'【引数】
'【戻り値】
'【備考】この例では実行ファイルと同じフォルダに出力する。
Sub OutputToTextFile()
Const FILE_NAME = "\Output.txt"
Dim FSO As Object
Dim TS As Object
Dim PathGetter As OMSGetter
Dim dicPath As Object
Dim path As Variant
Dim arrTmp As Variant
Dim sheetName As Variant
Dim strREC As String ' 書き出すレコード内容
'指定ファイルをOPEN(出力モード)
Set FSO = CreateObject("Scripting.FileSystemObject")
Set TS = FSO.CreateTextFile( _
Filename:=ThisWorkbook.path & FILE_NAME, _
Overwrite:=True)
'テキストデータの書き出し
strREC = "サンプルテキスト"
TS.WriteLine strREC
TS.Close
Set TS = Nothing
Set FSO = Nothing
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.