J
James Reid
I'm proud of myself. I actually came up with a very useful Word VBA
macro without having to ask anyone how to do it:
Sub Macro2()
Dim theFileName As String
theFileName = Dir("C:\Temp\*.htm")
Do While Len(theFileName) > 0
ChangeFileOpenDirectory "C:\Temp\"
Documents.Open FileName:=theFileName
Application.Run MacroName:="Normal.NewMacros.Macro1"
ChangeFileOpenDirectory "C:\Temp2\"
ActiveDocument.SaveAs FileName:=theFileName, _
FileFormat:=wdFormatFilteredHTML
ActiveWindow.Close
theFileName = Dir
Loop
End Sub
This time-saving macro opens an .htm file in "C:\Temp", edits it by
running a macro called "Macro1", and then saves it as an .htm file by
the same name in folder "C:\Temp2". Then it automatically repeats the
procedure for all of the other .htm files in folder "C:\Temp".
I found out how to do the above for one file by recording a macro while
going through the procedure manually, but this didn't tell me how to
perform the operation on multiple files automatically. For that
information I did a search and found the following old posting on this
same amazing news-group (microsoft.public.word.vba.general):
http://groups.google.com/group/microsoft.public.word.vba.general/msg/0b1408cc4f19cd26
Hooray for Google Groups! I love you!
macro without having to ask anyone how to do it:
Sub Macro2()
Dim theFileName As String
theFileName = Dir("C:\Temp\*.htm")
Do While Len(theFileName) > 0
ChangeFileOpenDirectory "C:\Temp\"
Documents.Open FileName:=theFileName
Application.Run MacroName:="Normal.NewMacros.Macro1"
ChangeFileOpenDirectory "C:\Temp2\"
ActiveDocument.SaveAs FileName:=theFileName, _
FileFormat:=wdFormatFilteredHTML
ActiveWindow.Close
theFileName = Dir
Loop
End Sub
This time-saving macro opens an .htm file in "C:\Temp", edits it by
running a macro called "Macro1", and then saves it as an .htm file by
the same name in folder "C:\Temp2". Then it automatically repeats the
procedure for all of the other .htm files in folder "C:\Temp".
I found out how to do the above for one file by recording a macro while
going through the procedure manually, but this didn't tell me how to
perform the operation on multiple files automatically. For that
information I did a search and found the following old posting on this
same amazing news-group (microsoft.public.word.vba.general):
http://groups.google.com/group/microsoft.public.word.vba.general/msg/0b1408cc4f19cd26
Hooray for Google Groups! I love you!