Word2007 文字変換マクロについて
以下のvbsファイルがエラーなってしまいます。
どう直したらよいかご教授お願いします。(マクロ初心者)
Const wdReplaceAll = 2
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set fs = CreateObject("Scripting.FileSystemObject")
Set objFolder = fs.GetFolder("D:\test")
For Each objFile in objFolder.Files
If Right(LCase(objFile.Name), 5) = ".docx" Then
Set objDoc = objWord.Documents.Open(objFolder.Path & "\" & objFile.Name)
Set objSelection = objWord.Selection
' objSelection.Find.Text = "A"
' objSelection.Find.Forward = True
' objSelection.Find.MatchWholeWord = True
' objSelection.Find.Replacement.Text = "B"
'----------------------------------------------------------
Open "D:\test\2.csv" For Input As #1
While Not EOF(1)
Line Input #1, a
s = Split(a, ",")
MsgBox s(0) & " " & s(1)
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
'----------------------------------------------------------
objSelection.Find.Text = s(0)
objSelection.Find.Forward = True
objSelection.Find.MatchWholeWord = True
objSelection.Find.Replacement.Text = s(1)
'----------------------------------------------------------
objSelection.Find.Wrap = wdFindContinue
objSelection.Find.Format = False
objSelection.Find.MatchCase = False
objSelection.Find.MatchWholeWord = False
objSelection.Find.MatchByte = False
objSelection.Find.MatchAllWordForms = False
objSelection.Find.MatchSoundsLike = False
objSelection.Find.MatchWildcards = False
objSelection.Find.MatchFuzzy = True
End With
Selection.Find.Execute Replace:=wdReplaceAll
Wend
Close #1
End Sub
'----------------------------------------------------------
If objSelection.Find.Execute( ,,,,,,,,,,wdReplaceAll) Then
objDoc.Save
End If
objDoc.Close
End If
Next
objWord.Quit