Convert 150 word docs to html via save as

  • Thread starter Thread starter hectorlopez
  • Start date Start date
H

hectorlopez

I have about 150 word documents which convert well to html when I us
the save as command. However I don't have time to convert them all on
by one to. How do I perform a save as commmand on all of them to htm
at once? thank you for your response
 
Put them all in a folder on their own and run the following macro

Public Sub BatchSaveAsHTML()
Dim myFile As String
Dim myHTML As String
Dim myLen As String
Dim myLen2 As String
Dim PathToUse As String
Dim myDoc As Document

With Dialogs(wdDialogCopyFile)
If .Display <> 0 Then
PathToUse = .Directory
Else
MsgBox "Cancelled by User"
Exit Sub
End If
End With

If Documents.Count > 0 Then
Documents.Close Savechanges:=wdPromptToSaveChanges
End If

If Left(PathToUse, 1) = Chr(34) Then
PathToUse = Mid(PathToUse, 2, Len(PathToUse) - 2)
End If

myFile = Dir$(PathToUse & "*.doc")

While myFile <> ""
Set myDoc = Documents.Open(PathToUse & myFile)
myLen = Len(myFile)
myLen2 = myLen - 3
myHTML = Left(myFile, myLen2) & "HTM"
myDoc.SaveAs FileName:=myHTML, FileFormat:=wdFormatHTML
myDoc.Close Savechanges:=wdSaveChanges
myFile = Dir$()
Wend
End Sub


--
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
Graham Mayor - Word MVP

Web site www.gmayor.com
Word MVP web site www.mvps.org/word
<>>< ><<> ><<> <>>< ><<> <>>< <>>< ><<>
 
Hi Hector,

You might look at the batch conversion wizard (File > New > Templates > On
my computer > Other documents).

Greetings,
Klaus
 
Back
Top