Wrote the code below to convert the dotx to docx file. Tried using both documents.open and documents.add but both doesn't output my new save files. Not sure where I went wrong and would appreciate any expert advise.
Sub ConvertFile()
Application.ScreenUpdating = False
Dim wdApp As New Word.Application
Dim wdDoc As Word.Document
Dim strFolder As String, strFile As String
Dim sDocName As String
strFolder = GetFolder
If strFolder = "" Then Exit Sub
strFile = Dir(strFolder & "\*.dotx", vbNormal)
wdApp.DisplayAlerts = False
While strFile <> ""
'Set wdDoc = wdApp.Documents.Open(Filename:=strFolder & "\" & strFile, AddtoRecentFiles:=False, Visible:=False, ReadOnly:=True)
Set wdDoc = wdApp.Documents.Add(Template:=strFolder & "\" & strFile, Visible:=False)
sDocName = Left(strFile, Len(strFile) - 5)
sDocName = sDocName & ".docx"
wdDoc.SaveAs2 Filename:=sDocName, FileFormat:=wdFormatDocumentDefault, AddtoRecentFiles:=False
wdDoc.Close SaveChanges:=False
strFile = Dir()
Wend
wdApp.Quit
Set wdDoc = Nothing: Set wdApp = Nothing: Set WkSht = Nothing
Application.ScreenUpdating = True
End Sub
Function GetFolder() As String
Dim oFolder As Object
GetFolder = ""
Set oFolder = CreateObject("Shell.Application").BrowseForFolder(0, "Choose a folder", 0)
If (Not oFolder Is Nothing) Then GetFolder = oFolder.Items.Item.Path
Set oFolder = Nothing
End Function