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!

Setting the title of a HTM page from Word by macro 1

Status
Not open for further replies.

JPJeffery

Technical User
May 26, 2006
600
GB
Hi

I've recorded an AutoClose() macro to save the document as a web page (.htm) but the macro doesn't record the entry to the Set Page Title dialogue:
Code:
Sub AutoClose()
'
' sawp Macro
' Macro recorded 25/08/2006 by Jeff Jeffery
'
    ActiveDocument.SaveAs FileName:="Doc1.htm", FileFormat:=wdFormatHTML, _
        LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
        :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
        SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
        False
    ActiveWindow.View.Type = wdWebView
End Sub

What gives? Did MS miss a trick?

More to the point, is there a way around this?

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
The title that is used for the HTMl title bar value is the ActiveDocument.BuiltInProperties(wdPropertyTitle). In other words...it is the title.

So, simple add a title:
Code:
ActiveDocument.BuiltInDocumentProperties("Title") = "The New Title"
If you want of course you could either bring up the SetTitle dialog, or make your own dialog. However, in any case, the title used by a browser is, the title of the file.

Gerry
My paintings and sculpture
 
That worked first time. Thank you!

Odd that the same code isn't recordable in a macro though...

JJ
[small][purple]Variables won't. Constants aren't[/purple][/small]
 
Actually, there a LOT of things that can not be done, or seen, with the macro recorder. In this case, when you change the title when recording the File SaveAsWeb Page, the only thing actually recorded is the result of the file save. The "manual" title change on the dialog is set, but it is...hmmmm, an internally re-routed procedure, and is not recorded.

Gerry
My paintings and sculpture
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top