【问题标题】:Macro to save documents generated with word/excel automatically自动保存使用 word/excel 生成的文档的宏
【发布时间】:2014-12-04 13:04:23
【问题描述】:

此时,我有一个文档,您可以在其中输入其他程序的多个输出,这些数据将根据您在组合框(表单控件)中选择的人转换为每个人的一些统计数据和图表。这在此刻工作正常。

Excel 连接到 MS Word 文档,该文档显示 Excel 文档中所选人员的图表和统计数据。

我想要一个按钮,可以自动将单个文档另存为具有不同名称的 PDF。

manual: open both documents
manual: click on the macro
macro: go to first of the combobox list (this can be done by changing output of combobox to 1)
loop
macro: open word and safe as pdf
macro: if number of people that have to be done is same as output combobox, end
macro: go to the next of the list (change output combobox by +1)
end loop

我试了好久还是没能成功,如果有人能帮忙,我将不胜感激!

我用的是office 2010

【问题讨论】:

    标签: excel vba pdf ms-word save


    【解决方案1】:

    要将文档另存为 PDF,您只需运行此行

    objWordDocument.SaveAs "C:\TEMP\Doc1.pdf", 17
    

    打开 Word 文档的按钮的完整代码如下。

    Sub SaveWordAsPDF()
    Dim wordObj
    Dim objWordDocument As Object
    Set wordObj = GetObject(, "Word.Application")
    Set objWordDocument = wordObj.Documents(1) '1 is the reference index to the documente, if there are more than 1 opened you need to see wich one is the one you want
    objWordDocument.SaveAs "C:\TEMP\Doc1.pdf", 17
    End Sub
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-11-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多