0

I need to open a large amount of documents that are currently saved in Publisher (2003, 2007, and 2010) and convert them to Word documents. These are simple one page text documents but I have about 1,000 of them to convert. Here is the code I have:

Public Sub Pub_To_Word()

Dim FS As New FileSystemObject
Dim pubApp As Publisher.Application
' Reference Library pointing to:
' Microsoft Scripting Runtime
' Microsoft Word 14.0 Object Library
Dim FSfolder As Folder
Dim MyFile As File
Dim mydoc As Document
Dim sFolderPath As String
Dim Table As Table


sFolderPath = "I:\My Documents\Publisher Test"
Set FSfolder = FS.GetFolder(sFolderPath)

For Each MyFile In FSfolder.Files

           Set mydoc = pubApp.Open(MyFile)
               Application.DisplayAlerts = False
               mydoc.SaveAs Filename:MyFile & ".docx", FileFormat:=wdFormatXMLDocument
               mydoc.Close savechanges:=True
           pubApp.DisplayAlerts = True

      End If

     Next

    End
End Sub

The code debugs at

 FileFormat:=wdFormatXMLDocument

I can't seem to get past this point.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Mike Marshall
  • 341
  • 4
  • 6
  • 19

1 Answers1

0

Not sure why you're doing it in Excel, but:

Edit: wdFormatXMLDocument might not be defined since you run the macro from Publisher, so the easiest would be to replace it by 12

Jbjstam
  • 874
  • 6
  • 13