Skip to content

Instantly share code, notes, and snippets.

@lunark
Last active June 25, 2020 08:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lunark/4351089 to your computer and use it in GitHub Desktop.
Save lunark/4351089 to your computer and use it in GitHub Desktop.
VBAマクロ向け関数。指定したパスに、変数の内容を、UTF-8のテキストファイルで書き出す関数。Microsoft JET 2.8以上必須です。
'******************************************************************
'■WriteUnicodePlainText関数
'UTF-8テキスト書き出し
' 引数1:書き出し先のフルパス
' 引数2:流し込みたい文字列が入った文字列変数
'Option Explicit必須、Microsoft JET2.8以上必須
'******************************************************************
Private Sub WriteUnicodePlainText(ByVal strFN As String, ByVal strTEXT As String)
Dim adodbStream As ADODB.Stream
Set adodbStream = New ADODB.Stream
adodbStream.Type = adTypeText
adodbStream.Charset = "UTF-8"
adodbStream.Open
adodbStream.WriteText strTEXT
adodbStream.SaveToFile (strFN), adSaveCreateOverWrite
adodbStream.Close
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment