如何批量将word转为html
展开全部
在Word中建立并运行此宏兄如程序
Sub DoctoHtml()
Dim FS As FileSearch, myFolder As String, myDialog As FileDialog
Dim i As Long, N As Long, myFileName As String
Dim myDoc As Document, strHtmlName As String
On Error Resume Next
Set myDialog = Application.FileDialog(msoFileDialogFolderPicker)
With myDialog
.Title = "请选择一个您需要进行羡扒启文件转换的文件夹"
If .Show <> -1 Then Exit Sub
myFolder = .InitialFileName
Set myDialog = Nothing
End With
Set FS = Application.FileSearch
With FS
.NewSearch
.LookIn = myFolder
.SearchSubFolders = True
.FileName = "*.doc"
If .Execute() > 0 Then
N = .FoundFiles.Count
For i = 1 To N
myFileName = CStr(.FoundFiles(i))
Application.StatusBar = "正在转换:" & myFileName & "…" & i & "/" & N
strHtmlName = VBA.Replace(myFileName, ".doc", ".hml", , , vbTextCompare)
Set myDoc = Word.Documents.Open(FileName:=myFileName, Visible:=True)
myDoc.SaveAs FileName:=strHtmlName, fileformat:=wdFormatHTML
myDoc.Close
Next
Application.StatusBar = Empty
MsgBox "Micorsoft Word共完成了" & N & "个Doc文件转换为Html文件工作!", vbInformation, "此指"
Else
MsgBox "Microsoft Word在" & myFolder & "文件夹中没有找到*.doc文件!", vbInformation, ""
End If
End With
End Sub
Sub DoctoHtml()
Dim FS As FileSearch, myFolder As String, myDialog As FileDialog
Dim i As Long, N As Long, myFileName As String
Dim myDoc As Document, strHtmlName As String
On Error Resume Next
Set myDialog = Application.FileDialog(msoFileDialogFolderPicker)
With myDialog
.Title = "请选择一个您需要进行羡扒启文件转换的文件夹"
If .Show <> -1 Then Exit Sub
myFolder = .InitialFileName
Set myDialog = Nothing
End With
Set FS = Application.FileSearch
With FS
.NewSearch
.LookIn = myFolder
.SearchSubFolders = True
.FileName = "*.doc"
If .Execute() > 0 Then
N = .FoundFiles.Count
For i = 1 To N
myFileName = CStr(.FoundFiles(i))
Application.StatusBar = "正在转换:" & myFileName & "…" & i & "/" & N
strHtmlName = VBA.Replace(myFileName, ".doc", ".hml", , , vbTextCompare)
Set myDoc = Word.Documents.Open(FileName:=myFileName, Visible:=True)
myDoc.SaveAs FileName:=strHtmlName, fileformat:=wdFormatHTML
myDoc.Close
Next
Application.StatusBar = Empty
MsgBox "Micorsoft Word共完成了" & N & "个Doc文件转换为Html文件工作!", vbInformation, "此指"
Else
MsgBox "Microsoft Word在" & myFolder & "文件夹中没有找到*.doc文件!", vbInformation, ""
End If
End With
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询