【问题标题】:Open Publisher files in a folder and save as Word documents打开文件夹中的 Publisher 文件并另存为 Word 文档
【发布时间】:2014-12-15 11:10:54
【问题描述】:

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

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

我似乎无法超越这一点。

【问题讨论】:

    标签: vba excel ms-word ms-publisher


    【解决方案1】:

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

    编辑: 由于您从 Publisher 运行宏,因此可能未定义 wdFormatXMLDocument,因此最简单的方法是将其替换为 12

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-16
      相关资源
      最近更新 更多