Reply
 
Thread Tools Display Modes
  #1   Report Post  
Groty
 
Posts: n/a
Default Export Individual Pages from a Doc

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   Report Post  
Doug Robbins
 
Posts: n/a
Default

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   Report Post  
Groty
 
Posts: n/a
Default

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   Report Post  
Graham Mayor
 
Posts: n/a
Default

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

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can you save individual document pages as seperate word files? John Calligy Mailmerge 2 April 12th 05 09:14 AM
how to move 7 scanned docs. to individual pages Andy Microsoft Word Help 5 April 5th 05 12:57 AM
Printing Page Ranges with page numbers i-iv then 1-23 for 27 total Scott Page Layout 2 February 9th 05 02:49 AM
back to back printing of individual pages within a document salvatore Mailmerge 1 February 6th 05 12:02 PM
Number of pages excluding content pages Number of pages excluding content pages Microsoft Word Help 4 January 11th 05 02:21 PM


All times are GMT +1. The time now is 08:57 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"