Home |
Search |
Today's Posts |
|
#1
![]() |
|||
|
|||
![]()
Hi,
Here's my overall problem : I have a 130 page Word Doc I need to export to HTML for posting on the intranet. The Export to HTML works fine, but I need to break the document up into 20+ different HTML pages, based on Chapters. How can I export a page range into a new Word Doc? I figure the simplest thing to do is create the 20 different docs, then convert them. Thanks |
#2
![]() |
|||
|
|||
![]()
The following will create a separate file for each page:
Sub splitter() ' ' splitter Macro ' Macro created 16-08-98 by Doug Robbins to save each page of a document ' as a separate file with the name Page#.DOC ' Selection.HomeKey Unit:=wdStory Pages = ActiveDocument.BuiltInDocumentProperties(wdPropert yPages) Counter = 0 While Counter Pages Counter = Counter + 1 DocName = "Page" & Format(Counter) ActiveDocument.Bookmarks("\Page").Range.Cut Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=DocName, FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False ActiveWindow.Close Wend End Sub If the 20 documents were separate Sections in the original documrent, then this should do what you want: Sub splitter() ' splitter Macro ' Macro created by Doug Robbins to save each letter created by a mailmerge as a separate file. Dim i As Long, Source as Document, Target as Document, Letter as Range Set Source = ActiveDocument For i = 1 to Source.Sections.Count Set Letter = Source.Sections(i).Range Letter.End=Letter.End-1 Set Target = Documents.Add Target.Range=Letter Target.SaveAs FileName:="Letter" & i Target.Close Next i End Sub -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Groty" wrote in message ... Hi, Here's my overall problem : I have a 130 page Word Doc I need to export to HTML for posting on the intranet. The Export to HTML works fine, but I need to break the document up into 20+ different HTML pages, based on Chapters. How can I export a page range into a new Word Doc? I figure the simplest thing to do is create the 20 different docs, then convert them. Thanks |
#3
![]() |
|||
|
|||
![]()
I'm running Word Version 11 w/SP1
It's Failing at: ActiveDocument.Bookmarks("\Page").Range.Cut With a Response Code of : Run-Time Error 4605 This method or property is not available because the object is empty. I have verified that it is retrieving the proper value for the length of the collection(number of pages). This is a bit frustrating for me. I'm pretty damned good with VBScript in IE. I just haven't ever found a good document explaining the the Word API. Thanks! "Doug Robbins" wrote: The following will create a separate file for each page: Sub splitter() ' ' splitter Macro ' Macro created 16-08-98 by Doug Robbins to save each page of a document ' as a separate file with the name Page#.DOC ' Selection.HomeKey Unit:=wdStory Pages = ActiveDocument.BuiltInDocumentProperties(wdPropert yPages) Counter = 0 While Counter Pages Counter = Counter + 1 DocName = "Page" & Format(Counter) ActiveDocument.Bookmarks("\Page").Range.Cut Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=DocName, FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False ActiveWindow.Close Wend End Sub If the 20 documents were separate Sections in the original documrent, then this should do what you want: Sub splitter() ' splitter Macro ' Macro created by Doug Robbins to save each letter created by a mailmerge as a separate file. Dim i As Long, Source as Document, Target as Document, Letter as Range Set Source = ActiveDocument For i = 1 to Source.Sections.Count Set Letter = Source.Sections(i).Range Letter.End=Letter.End-1 Set Target = Documents.Add Target.Range=Letter Target.SaveAs FileName:="Letter" & i Target.Close Next i End Sub -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Groty" wrote in message ... Hi, Here's my overall problem : I have a 130 page Word Doc I need to export to HTML for posting on the intranet. The Export to HTML works fine, but I need to break the document up into 20+ different HTML pages, based on Chapters. How can I export a page range into a new Word Doc? I figure the simplest thing to do is create the 20 different docs, then convert them. Thanks |
#4
![]() |
|||
|
|||
![]()
Split it before you convert to html. There are no pages to split in html
format. The following modification to Doug's code should allow the original Word document to be split & converted to html. Sub splitter() Selection.HomeKey Unit:=wdStory Pages = ActiveDocument.BuiltInDocumentProperties(wdPropert yPages) Counter = 0 While Counter Pages Counter = Counter + 1 DocName = "Page" & Format(Counter) ActiveDocument.Bookmarks("\Page").Range.Cut Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=DocName, _ FileFormat:=wdFormatHTML ActiveWindow.Close Wend End Sub -- Graham Mayor - Word MVP My web site www.gmayor.com Word MVP web site http://word.mvps.org Groty wrote: I'm running Word Version 11 w/SP1 It's Failing at: ActiveDocument.Bookmarks("\Page").Range.Cut With a Response Code of : Run-Time Error 4605 This method or property is not available because the object is empty. I have verified that it is retrieving the proper value for the length of the collection(number of pages). This is a bit frustrating for me. I'm pretty damned good with VBScript in IE. I just haven't ever found a good document explaining the the Word API. Thanks! "Doug Robbins" wrote: The following will create a separate file for each page: Sub splitter() ' ' splitter Macro ' Macro created 16-08-98 by Doug Robbins to save each page of a document ' as a separate file with the name Page#.DOC ' Selection.HomeKey Unit:=wdStory Pages = ActiveDocument.BuiltInDocumentProperties(wdPropert yPages) Counter = 0 While Counter Pages Counter = Counter + 1 DocName = "Page" & Format(Counter) ActiveDocument.Bookmarks("\Page").Range.Cut Documents.Add Selection.Paste ActiveDocument.SaveAs FileName:=DocName, FileFormat:= _ wdFormatDocument, LockComments:=False, Password:="", AddToRecentFiles:= _ True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:= _ False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False ActiveWindow.Close Wend End Sub If the 20 documents were separate Sections in the original documrent, then this should do what you want: Sub splitter() ' splitter Macro ' Macro created by Doug Robbins to save each letter created by a mailmerge as a separate file. Dim i As Long, Source as Document, Target as Document, Letter as Range Set Source = ActiveDocument For i = 1 to Source.Sections.Count Set Letter = Source.Sections(i).Range Letter.End=Letter.End-1 Set Target = Documents.Add Target.Range=Letter Target.SaveAs FileName:="Letter" & i Target.Close Next i End Sub -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Groty" wrote in message ... Hi, Here's my overall problem : I have a 130 page Word Doc I need to export to HTML for posting on the intranet. The Export to HTML works fine, but I need to break the document up into 20+ different HTML pages, based on Chapters. How can I export a page range into a new Word Doc? I figure the simplest thing to do is create the 20 different docs, then convert them. Thanks |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Can you save individual document pages as seperate word files? | Mailmerge | |||
how to move 7 scanned docs. to individual pages | Microsoft Word Help | |||
Printing Page Ranges with page numbers i-iv then 1-23 for 27 total | Page Layout | |||
back to back printing of individual pages within a document | Mailmerge | |||
Number of pages excluding content pages | Microsoft Word Help |