excelvbaでファイルに書き込む

Public Sub sample()
    Dim intNo As Integer
    Dim strFileName As String

    ' テキストを出力するファイルを設定
    strFileName = "C:\tmp\sample.txt"

    ' ファイルの書き込み
    intNo = FileSystem.FreeFile()           ' フリーファイルNoを取得
    Open strFileName For Output As #intNo   ' 上書きモードでファイルをオープン
    Print #intNo, "ABCDE"
    Print #intNo, "あいうえお"
    Close #intNo                            ' ファイルをクローズ

End Sub

ネタ元