2014-10-20 160 views
0

我需要打开当前保存在Publisher(2003,2007和2010)中的大量文档并将它们转换为Word文档。这些只是简单的一页文本文件,但我有大约1000个要转换。这里是我的代码:在一个文件夹中打开Publisher文件并保存为Word文档

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 

代码调试在

FileFormat:=wdFormatXMLDocument 

我似乎无法让过去这一点。

回答

0

不知道为什么你在Excel中做,但是:

编辑: wdFormatXMLDocument可能无法定义,因为您从发布的宏,所以最简单的将取代它12

相关问题