0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

メモ2

Last updated at Posted at 2025-09-09
' UTF-8 (BOMなし) + LF
  ' いったん UTF-8(BOM付き)でStreamに書く
    Set stmText = CreateObject("ADODB.Stream")
    With stmText
        .Type = 2
        .Charset = "utf-8"
        .Open
        .WriteText outText, 0
        .Flush
        .Position = 0
        .Type = 1                 ' バイナリに切替
        If .Size >= 3 Then .Position = 3  ' BOM(3バイト)をスキップ
    End With

    ' 出力(バイナリ)
    Set stmOut = CreateObject("ADODB.Stream")
    With stmOut
        .Type = 1
        .Open
        remain = stmText.Size - stmText.Position
        If remain > 0 Then
            bytes = stmText.Read(remain)   ' Variant(Byte())
            .Write bytes
        End If
        .SaveToFile filePath, 2
        .Close
    End With

    stmText.Close

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?