macros自动保存用word / excel生成的文档

此时,我有一个文件,您可以从其他程序中input多个输出,根据您在combobox(表格控件)中select的人数将这些数据转换为每个人的统计数据和图表。 这个工作正常。

excel连接到一个MS Word文档,该文档显示Excel文档中select的人员的graphics和统计信息。

我想有一个button,可以自动将单个文档保存为不同名称的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 

我已经尝试了很长时间,但不能pipe理它,如果有人能帮助,我会非常感激!

我使用Office 2010

要将文档保存为PDF,只需要运行这一行

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

下面是完整的代码到一个打开的Word文档的button。

 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