Save each page as seperate HTML or PDF file 
Author Message
 Save each page as seperate HTML or PDF file

Hi everyone,
just wondered if anyone had any tips on saving each page
of a 250 page document as seperate files, in either HTML
or PDF (I have Acrobat Writer 5 installed) preferably, but
Word or RTF would do. The first 4 characters of each page
identify the page uniquely (each page is a different
conference abstract) and would make good file names. Can
anyone save me from days of cutting and pasting?
Thanks in advance, Rod.


Mon, 28 Feb 2005 19:21:16 GMT  
 Save each page as seperate HTML or PDF file
Hi Rod,

I wrote the following macro for someone who wanted different HTML files for each page of the opened document. Note that the code is for Word 2000, if you need Word 97, it's a bit different. Please post back if you need help with that.

You can incorporate this macro in one that batch process all files in a give directory. I enclosed an example on how to do that as well:

--------------------------------------------------------
Sub ExtractPage()
Dim i As Integer
Dim iNumPages As Integer
Dim sCurrentDoc As String

  sCurrentDoc = ActiveDocument.Name
  'Get the current document's name
  iNumPages =
ActiveDocument.Content.Information(wdActiveEndAdjustedPageNumber)
  'Get the number of pages
  For i = 1 To iNumPages
   'For as many times as there are pages
    Selection.GoTo What:=wdGoToPage, which:=wdGoToAbsolute, Count:=i
    'Goto pagenumber i
    Selection.GoTo What:=wdGoToBookmark, Name:="\Page"
    'Select this page
    Selection.Copy
    'Copy the selection
    Documents.Add
    'Add a new document
    Selection.Paste
    'Paste
    ActiveDocument.SaveAs FileName:="newdocument" & i, _
                          fileformat:=wdFormatHTML
    'Save the new document as "newdocument" and the value of the counter i
    ActiveDocument.Close
    'Close this new document
    Documents(sCurrentDoc).Activate
    'Activate the document where we started from
  Next i

End Sub
--------------------------------------------------------

Here's an example on how to open all files in a specified folder. You can
write or record another macro that does specific actions for the opened
document and call that from the first macro once each document is opened.
---------------------------------------------------------
Sub ProcessFilesInFolder()
Dim sFileName As String
Dim sFolder As String

  'Replace with your own foldername
  sFolder = "C:\My Documents\"
  sFileName = Dir(sFolder & "*.doc")

  Do While sFileName <> ""
    Documents.Open (sFolder & sFileName)
    'run a macro from here to process the active document
    'Name of macro
    ActiveDocument.Close savechanges:=wdSaveChanges
    sFileName = Dir()
  Loop

End Sub
---------------------------------------------------------

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/


Quote:
> Hi everyone,
> just wondered if anyone had any tips on saving each page
> of a 250 page document as seperate files, in either HTML
> or PDF (I have Acrobat Writer 5 installed) preferably, but
> Word or RTF would do. The first 4 characters of each page
> identify the page uniquely (each page is a different
> conference abstract) and would make good file names. Can
> anyone save me from days of cutting and pasting?
> Thanks in advance, Rod.



Tue, 01 Mar 2005 05:47:31 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Save current html page as html file

2. saving html page to a file

3. SAving a MS Word file to a PDF file and a text file

4. Merge Pdf and aspx(html) pages

5. Saving a Merge document as seperate files.

6. Saving HTML/rich format into HTML file

7. PDF Pages - pdf.ocx

8. Using WIN32 API to generate PDF files from HTML

9. Saving an Access97 Report as a PDF file

10. Saving report output to PDF File

11. How can i save html page of iexplorer(or netscape)

12. Saving a report as a .pdf file

 

 
Powered by phpBB® Forum Software