2014-10-20 189 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

相關問題