View Single Post
 
Old 02-04-2018, 11:25 PM
Prateep Nath Prateep Nath is offline Windows XP Office 2016
Novice
 
Join Date: Feb 2018
Posts: 1
Prateep Nath is on a distinguished road
Default Run macro to save multiple word docs and xml

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

Last edited by macropod; 02-05-2018 at 02:47 PM. Reason: Added code tags
Reply With Quote