vbaでhtmlをじぇねれーと
ジェネレータと呼べるものじゃないけど、vbaで書く必要が有ったのでメモ
作ったファイルはeuc-jpでエンコード。
'ブックと同じ位置にsample.htmlを作成
GenerateHTML (ThisWorkbook.Path & "\sample.html")
Private Sub GenerateHTML(outfile As String)
'ファイル番号1で新規作成
Open outfile For Output As #1
'データ書き込み
Print #1, "<?xml version=""1.0"" encoding=""EUC-JP""?>"
Print #1, "<html>"
Print #1, "<head>"
Print #1, "<meta http-equiv=""Content-Type"" content=""text/html; charset=EUC-JP"">"
Print #1, "<title>sample</title>"
......
Print #1, "</body>"
Print #1, "</html>"
'クローズ
Close #1
'文字コード変換
ShiftJisToEucJp (outfile)
End Sub
'Shift_JIS -> EUC-JP
Private Sub ShiftJisToEucJp(Filename As String)
Dim FirstObj As Object
Dim SecondObj As Object
Set FirstObj = CreateObject("ADODB.Stream")
With FirstObj
.Type = 2
.Charset = "Shift_JIS"
.Open
.LoadFromFile Filename
.Position = 0
End With
Set SecondObj = CreateObject("ADODB.Stream")
With SecondObj
.Type = 2
.Charset = "EUC-JP"
.Open
End With
FirstObj.copyto SecondObj
SecondObj.Position = 0
SecondObj.savetofile "sample.html", 2
End Sub