View Single Post
 
Old 08-05-2019, 12:15 PM
d4okeefe d4okeefe is offline Windows 10 Office 2016
Advanced Beginner
 
Join Date: Apr 2013
Posts: 77
d4okeefe is on a distinguished road
Default

How about something like this? I think you need to pass the document to the SaveAsDoc function.

Code:
Sub SaveAsDoc(d As Document)
    Dim newfile As String
    If InStrRev(d.Name, ".html") > 0 Then
        newfile = Replace(d, ".html", ".doc")
    ElseIf InStrRev(d.Name, ".htm") > 0 Then
        newfile = Replace(d, ".htm", ".doc")
    End If
    d.SaveAs2 newfile, FileFormat:=wdFormatDocument97
End Sub
Sub ConvertHTMLtoDOC()
    Dim file
    Dim path As String
    path = "C:\scratch\"
    
    file = Dir(path & "*.htm*")
    Do While file <> ""
        Dim d As Document
        Set d = Documents.Open(file)
        
        Call SaveAsDoc(d)
        d.Close
        file = Dir()
    Loop
End Sub
Reply With Quote