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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word "Save as html..." macro

Status
Not open for further replies.

groovygarden

Programmer
Aug 23, 2001
63
Hi,

I have a macro which allows people in my department to save a file normally and also save it as a htm file to our website.


ActiveDocument.Save
ChangeFileOpenDirectory "\\war00160\c$\Inetpub\ ActiveDocument.SaveAs FileName:="?????.htm", FileFormat:=wdFormatHTML, AddToRecentFiles:=True
End Sub


This works fine, except that that the htm file name should be the same as the normal (.doc) file. So if I have an existing document called test.doc, when I run this macro I want it to save changes to test.doc, but also to save a .htm version in the specified folder with the name test.htm. How do I specify the name of the .htm page?

I know could code it in (FileName:="test.htm") but this would mean a different macro for each file...

Hope I've explained this OK! Any help appreciated!
 
Will this work?...
Code:
Sub test()

Dim docName1 As String
Dim docName2 As String

docName1 = ActiveDocument.Name
docName2 = Left(docName1, Len(docName1) - 3) & "htm"

ActiveDocument.SaveAs FileName:=docName2, _
 FileFormat:=wdFormatHTML, AddToRecentFiles:=True

End Sub
All the best, SteveB.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top