Solved

How to retreive single page content in VBA MS-Word2007

Posted on 2009-05-08
3
167 Views
Last Modified: 2013-11-10
I have the necessity to create from a .DOC file, for each page in it, a page.html
I explain better, for each page in the .DOC document I need to create a single HTML document.
from A.doc -> to -> Apage1.html, Apage2.html, Apage3.html
All this with VBA.
How can I do?
Thanks.
0
Comment
Question by:bobdylan75
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 24337629
Hi. bobdylan75.  

Try this.
Sub SavePages()
    Dim wrdDoc1 As Word.Document, _
        wrdDoc2 As Word.Document, _
        wrdRange As Word.Range, _
        intPages As Integer
    Set wrdDoc1 = ActiveDocument
    On Error Resume Next
    For intPages = 1 To ActiveDocument.ActiveWindow.Panes(1).Pages.Count
        Set wrdRange = ActiveDocument.Range
        Selection.GoTo wdGoToPage, wdGoToAbsolute, intPages
        Set wrdRange = ActiveDocument.Bookmarks("\Page").Range
        wrdRange.Copy
        Set wrdDoc2 = Application.Documents.Add
        wrdDoc2.Range.Paste
        wrdDoc2.SaveAs wrdDoc1.Name & "-Page" & intPages & ".html", wdFormatHTML
        wrdDoc2.Close
        Set wrdDoc2 = Nothing
    Next
End Sub

Open in new window

0
 

Author Closing Comment

by:bobdylan75
ID: 31579386
You are not a sage, you are something like a cyber-god!
thank you!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24344153
LOL!  Thanks and you're welcome.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

737 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question