View Single Post
 
Old 08-06-2019, 12:36 AM
gmayor's Avatar
gmayor gmayor is offline Windows 10 Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The issue is primarily related to the filename. What you need is

Code:
Sub ConvertHTMLtoDOC()
Dim strFile As String
Dim strPath As String
Dim strDocName As String
Dim oDoc As Document
    strPath = "C:\scratch\"
    strFile = Dir(strPath & "*.htm*")
    Do While strFile <> ""
        Set oDoc = Documents.Open(strPath & strFile) 'This line needs to include the path
        strDocName = Left(oDoc.FullName, InStrRev(oDoc.FullName, ".") - 1) & ".docx"
        oDoc.SaveAs2 FileName:=strDocName, FileFormat:=wdFormatDocumentDefault
        oDoc.Close
        strFile = Dir()
    Loop
    Set oDoc = Nothing
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote