View Single Post
 
Old 10-10-2020, 05:12 AM
kishan patel kishan patel is offline Windows 10 Office 2019
Novice
 
Join Date: Oct 2020
Posts: 2
kishan patel is on a distinguished road
Post I got error for Macro script when I used for split large file and convert as HTML

Dear all,

I have a large file around 1300 pages and wanted to split by pages and also change file formate as HTML but getting error.

My Macro script is,

Sub BreakOnPage()
' Used to set criteria for moving through the document by page.
Application.Browser.Target = wdBrowsePage

For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")

'Select and copy the text to the clipboard
ActiveDocument.Bookmarks("\page").Range.Copy

' Open new document to paste the content of the clipboard into.
Documents.Add
Selection.Paste
' Removes the break that is copied at the end of the page, if any.
Selection.TypeBackspace
ChangeFileOpenDirectory "C:"
DocNum = DocNum + 1
ActiveDocument.SaveAs FileName:="page_" & DocNum & ".html
ActiveDocument.Close

' Move the selection to the next page in the document
Application.Browser.Next
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub


Aprreciated for your help.
Reply With Quote