Hello all,
I am trying to write a macro to convert all the word docs in a specific folder into flat XML . I have been able to come up with the below code, but it's not working.
can anyone please let me know how to resolve it.
Code:
Sub BatchConvertDocToXML()
Dim objDoc As Document
Dim strFile As String, strFolder As String
'Initialization
strFolder = "D:\XXXX\Original\"
strFile = Dir(strFolder & "*.doc", vbNormal)
'Process each file in the file folder and convert them to xml.
While strFile <> ""
Set wdDoc = Documents.Open(FileName:=strFolder & strFile, AddToRecentFiles:=False, Visible:=False)
'insert code here
wdDoc.SaveAs2 FileName:=strFile, FileFormat:=wdFormatFlatXML, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False, CompatibilityMode:=15
wdDoc.Close
strFile = Dir()
Wend
End Sub