Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word to Html saving problem

Status
Not open for further replies.

Freemo

MIS
Oct 25, 2005
71
GB
Hello

I spent weeks designing a programme to save word documents to HTML and then storing them on the web for viewing. I got it sorted and then in my happiest hour, i found a major problem that nearly persuaded me to throw myself out of my 3rd floor window.

The problem is that some of the documents my programme is designed for includes headers, footers and some even have watermarks. And these as i'm aware, are not supported for the saving to HTML.

I am in desperate need, as if there is no hope, i will have to go back to the drawing board and design it all again.
 
Well, M$Word *should* give you a warning:
Saving <whateverfilename.html> in this format (some format mentioned here) will remove Office-specific tags. Some Office features may not be available when you reopen this page. Do you want to save the document in this format?

* To save, click Yes
* To preserve formatting, click No. Then save the document in Web Page format (HTML)

And do not throw yourself out of my 3rd floor window, you will just hurt yourself. Go up to the top floor instead and try from there.

---- Andy
 
Thanx for the reply Andrzejek, but i am saving the document as html from vb using the following code and no warnings show up.

Set WdApp = GetObject(, "Word.Application")

WdApp.ActiveDocument.SaveAs FileName:="c:\" & rs1!lexcode & ".htm", FileFormat:=wdFormatHTML, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
 
You may want to ask this question in a more Word-specific forum, such as the VBA forum.

HTH

Bob
 
Hi Freemo,

I think what you'll have to do is cycle through all word pages and copy the headers/footers to top/base of each page before saving as html.

I've written something crude from scratch in Word-VBA. You'll have to adapt it to your VB code (with respective variable for the Word application), but it might help you on your way.

Beware: this is not tested and might still contain some bugs:
Code:
Sub CopyHeadersToPage()
Dim pagecount As Long, thePane As Pane
    If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
        ActiveWindow.Panes(2).Close
    End If
    If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
        ActivePane.View.Type = wdOutlineView Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    End If
    
    pagecount = ActiveDocument.BuiltInDocumentProperties("Number of Pages")

Selection.HomeKey unit:=wdStory
    For i = 1 To pagecount
        ActiveWindow.Panes(i).View.SeekView = wdSeekCurrentPageHeader
        Selection.WholeStory
        Selection.Copy
        ActiveWindow.Panes(i).View.SeekView = wdSeekMainDocument
        Selection.GoToNext wdGoToPage
        Selection.MoveUp wdLine, 1
        Selection.Paste
        Selection.TypeText vbCrLf
        Selection.GoToNext wdGoToPage
    Next i
    
End Sub

Hope this helps you.

Cheers,
Andy

[blue]Speak out against Human Rights violations in China/Tibet
[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top