用word宏命令批量实现html文件转word
Sub HtmltoWord() Dim MyFile As String Dim Arr(1000) As String '一次处理最大的文件数量,根据需要修改数字1000改为需要处理的数量 Dim count As Integer MyFile = Dir("D:\My Documents\2019\" & "*.html") count = count + 1 Arr(count) = MyFile Do While MyFile <> "" MyFile = Dir If MyFile = "" Then Exit Do End If count = count + 1 Arr(count) = MyFile '将文件的名字存在数组中 Loop For i = 1 To count Documents.Open FileName:="D:\My Documents\2019\" & Arr(i), ConfirmConversions:=False, ReadOnly:= _ False, AddToRecentFiles:=False, PasswordDocument:="", PasswordTemplate:= _ "", Revert:=False, WritePasswordDocument:="", WritePasswordTemplate:="", _ Format:=wdOpenFormatAuto, XMLTransform:="" ActiveDocument.SaveAs FileName:="D:\My Documents\2019\" & Replace(Arr(i), ".html", ".doc"), FileFormat:=wdFormatDocument, _ LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _ :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _ SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _ False ActiveDocument.Close Next End Sub
不知何原因,多次运行时出错。 求修改。
|