发布网友 发布时间:2022-04-22 04:13
共2个回答
热心网友 时间:2023-09-22 16:42
1、首先在Word里面打开原始文档;
2、键入Alt+F11打开VBA编辑器;
3、选择菜单命令“插入-模块”;
4、在代码编辑区中输入如下代码:
Option Explicit
Sub SavePagesToMultipleHTMLFiles()
Dim oSourceDoc As Document
Dim oNewDoc As Document
Dim strBaseName As String, strTargetFileName As String
Dim nIndex As Integer
Dim fs As Object
Set oSourceDoc = ActiveDocument
Set fs = CreateObject("Scripting.FileSystemObject")
strBaseName = fs.BuildPath(fs.GetParentFolderName(oSourceDoc.FullName), fs.GetBaseName(oSourceDoc.FullName))
Application.Browser.Target = wdBrowsePage
Selection.GoTo What:=wdGoToPage, Which:=Word.wdGoToFirst
For nIndex = 1 To oSourceDoc.BuiltInDocumentProperties("Number of Pages")
ActiveDocument.Bookmarks("\Page").Range.Copy
Set oNewDoc = Documents.Add
oNewDoc.Range.Paste
strTargetFileName = strBaseName & "_" & nIndex & ".html"
oNewDoc.SaveAs2 strTargetFileName, wdFormatHTML
oNewDoc.Close
Application.Browser.Next
Next
MsgBox "完成!"
End Sub
5、键入F5,运行。
6、检查在原文档相同目录下生成了若干个HTML文件,文件名是原文件后面加_1、_2、_3等,每个HTML文件对应原来一个页面的内容。
_________________________
补充:
请问出现什么错误?出错时是否高亮了代码的具体哪一行?
热心网友 时间:2023-09-22 16:42
有人提议国防大臣特vtedfdetc山西人才人人才市场为瓦房店市va