View Single Post
 
Old 08-05-2019, 11:53 AM
LBruce LBruce is offline Windows 10 Office 2013
Novice
 
Join Date: Aug 2019
Posts: 9
LBruce is on a distinguished road
Default

Thanks, but it looks like I may not have been perfectly clear.

I need a macro to open every HTM or HTML file in a specific folder and convert them all, saved in the same folder with the original file name. I have part of the VBA enough to open and close the files throughout the directory (copied from a macro from another process of mine), but am missing the steps to save a copy as a Word doc.

The "Call to SaveAsDocx" part is what I can't figure out.

Code:
Sub ConvertHTMLtoDOC()
Dim file
Dim path As String

' Path to your folder. Make SURE you include the terminating "\"
'YOU MUST EDIT THIS.
path = "\\MYPATH"

'Change this file extension to the file you are opening. .htm is listed below.
'YOU MAY NEED TO EDIT THIS.
file = Dir(path & "*.htm*")
Do While file <> ""
Documents.Open FileName:=path & file

' This is the call to the macro you want to run on each file the folder
Call SaveAsDocx

ActiveDocument.Close

' set file to next in Dir
file = Dir()
Loop
End Sub
Reply With Quote