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!

VBScript to convert .doc to .htm

Status
Not open for further replies.

dhamal1

IS-IT--Management
Jan 7, 2008
6
US
Hi,
I have macro below which converts .doc to .him. Can anyone write me a VBScrpit using this or your own programmin knowledge? I would really appriciate your time.

thaks.


Sub SaveToHTML()
'
' SaveToHTML Macro
Dim inputFolder As String, outputFolder As String
Dim docFile As String, htmlFile As String

' set input and output folders here

inputFolder = "C:\Documents and Settings\"

outputFolder = "C:\Documents and Settings\Newdocs\"

'get ready to load files

'look for *.doc files

docFile = Dir(inputFolder & IIf(Right(inputFolder, 1) <> "\", "\", "") & "*.doc")

While docFile <> "" ' For each file...

' ... load the file, ...

ChangeFileOpenDirectory inputFolder

Documents.Open FileName:=docFile, ConfirmConversions:=False _

, ReadOnly:=False, AddToRecentFiles:=False, PasswordDocument:="", _

PasswordTemplate:="", Revert:=False, WritePasswordDocument:="", _

WritePasswordTemplate:="", Format:=wdOpenFormatAuto, XMLTransform:=""

' ... export it, ...

htmlFile = Left(docFile, Len(docFile) - 3) & "htm"

ChangeFileOpenDirectory outputFolder

ActiveDocument.SaveAs FileName:=htmlFile, FileFormat:= _

wdFormatHTML, LockComments:=False, Password:="", AddToRecentFiles:=True, _

WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _

SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _

False

' ... and close it.

ActiveWindow.Close

' then get next file

docFile = Dir

Wend

MsgBox "done!"
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top