View Single Post
 
Old 02-05-2018, 02:52 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Try:
Code:
Sub BatchConvertDocToXML()
Dim wdDoc 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, ReadOnly:=True, AddToRecentFiles:=False, Visible:=False)
  wdDoc.SaveAs2 FileName:=strFolder & Split(strFile, ".doc")(0) & ".xml", FileFormat:=wdFormatFlatXML, AddToRecentFiles:=False
  wdDoc.Close False
  strFile = Dir()
Wend
End Sub
PS: When posting code, please use the code tags, indicated by the # button on the posting menu. Without them, your code loses much of whatever structure it had.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote