「ByRef引数の型が一致しません」助けてください。
お世話になります。
現在VBAでHTMLの書き出し用プログラムを書いています。
書き出したHTMLをUTF-8に変換するため、
■UTF-8ファイル作成 for VBA
http://www.vector.co.jp/soft/dl/winnt/prog/se320375.html
のクラスモジュールを利用させていただいております。
Sub testAで定義した内容を書き出すために、
Sub createTestでtestA fNum(i)とした場合、
「ByRef引数の型が一致しません」と怒られてしまいます…。
単数の生成であれば、testA f1で生成可能なのですが、
生成ファイルが複数あり、配列に格納して処理したいのです。
どなたかお力をお貸しください。
プログラムの知識はほぼ素人レベルですorz
宜しくお願いします。
▼コード
Option Explicit
Public Sub createTest()
Dim fNum As Variant
Dim f1 As New TextFile, f2 As New TextFile, f3 As New TextFile, f4 As New TextFile, f5 As New TextFile, f6 As New TextFile
Dim f7 As New TextFile, f8 As New TextFile, f9 As New TextFile, f10 As New TextFile, f11 As New TextFile, f12 As New TextFile
Dim f13 As New TextFile, f14 As New TextFile, f15 As New TextFile, f16 As New TextFile, f17 As New TextFile
Dim Header As String, BodyS_T As String, BodyS_L As String, GlNavi As String, Promo As String, Contents As String, PrNavi As String, SeNavi As String, Footer As String, BodyE As String
Dim ContentsM As String, ContentsS As String
Dim WBK As Workbook
Dim SH2 As Worksheet
Dim TplBox As Variant
Dim createCurPath As String
Dim i As Integer
Set WBK = ThisWorkbook
Set SH2 = WBK.Sheets(2)
createCurPath = ThisWorkbook.path & "\" & UserForm1.TextBox1.Value
fNum = Array(f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17)
'<HEADER>
Header = "Header"
'<BODY-START>
BodyS_T = "BodyS_T>"
BodyS_L = "BodyS_L"
'<GLOBAL NAVI>
GlNavi = "GlNavi"
'<PROMO>
Promo = "Promo"
'<CONTENTS>
Contents = "Contents"
ContentsM = "ContentsM"
ContentsS = "ContentsS"
'<PRIMRY NAVi>
PrNavi = "PrNavi"
'<SECONDARY NAVI>
SeNavi = "SeNavi"
'<FOOTER>
Footer = "Footer"
'<BODY-END>
BodyE = "BodyE"
For i = 0 To 16
If i = 0 Then
fNum(i).FileCreate createCurPath & "\index.html", "UTF-8"
ElseIf UserForm1("TextBox" & i + 1).Value <> "" Then
fNum(i).FileCreate createCurPath & "\" & UserForm1("TextBox" & i + 1).Value & "\index.html", "UTF-8"
End If
fNum(i).TextWriteLine Header
If i = 0 Then
fNum(i).TextWriteLine BodyS_T
ElseIf UserForm1("TextBox" & i + 1).Value <> "" Then
fNum(i).TextWriteLine BodyS_L
End If
TplBox = SH2.Range("C" & i + 3).Value
If TplBox <> "" Or TplBox <> "選択" Then
If InStr(TplBox, "-TA-") > 0 Then
testA fNum(i)
fNum(i).TextWriteLine Promo
fNum(i).TextWriteLine PrNavi
ElseIf InStr(TplBox, "-TB-") > 0 Then
testA fNum(i)
fNum(i).TextWriteLine "<hr />"
ElseIf InStr(TplBox, "-TC-") > 0 Then
fNum(i).TextWriteLine ContentsS
End If
End If
fNum(i).FileClose
Next i
End Sub
Public Sub testA(f As TextFile)
f.TextWriteLine "テスト1"
End Sub
お礼
回答ありがとうございます。 おかげさまでうまく作動しました! 本当にありがとうございました。