Created
March 16, 2012 05:11
-
-
Save nobrinskii/2048582 to your computer and use it in GitHub Desktop.
[vba/excel] テキストファイルにデータを書き出す
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'------------------------------------------------------------------------------ | |
'テキストファイルにデータを書き出す | |
'------------------------------------------------------------------------------ | |
'【引数】 | |
'【戻り値】 | |
'【備考】この例では実行ファイルと同じフォルダに出力する。 | |
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