此时,我有一个文档,您可以从其他程序输入多个输出,这些数据将转换为每个人的一些统计数据和图表,具体取决于您在组合框中选择的人(表单控件)。这个时候这很好用。
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
答案 0 :(得分: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