作者:mobiledu2502869373 | 来源:互联网 | 2023-05-19 06:24
Iwanttoautomatetheprint2PDFprocedureinMicrosoftWordforusewithDragonNaturallySpeaking.
I want to automate the print2PDF procedure in Microsoft Word for use with Dragon NaturallySpeaking.
我想在Microsoft Word中自动化print2PDF过程,以便与Dragon自然结合使用。
I created this macro which is executed when the user has a document opened and says "Print to PDF":
我创建了这个宏,当用户打开一个文档并说“打印到PDF”时执行:
Sub Main
'On Error GoTo errorHandler
Set wApp = GetObject(,"Word.Application")
If wApp.Documents.Count >= 1 Then
wApp.ActiveDocument.ExportAsFixedFormat OutputFileName :="tst1.pdf", _
ExportFormat := wdExportFormatPDF, _
UseISO19005_1 := True
Else
MsgBox "Kein Dokument geöffnet"
End If
Set wApp = Nothing
Exit Sub
errorHandler:
MsgBox "Ein Fehler ist aufgetreten. Kontaktieren Sie Helpdesk."
Set wApp = Nothing
End Sub
However upon execution I always get Error 80070057. I googled the error code and it says "invalid arguements", but I can't explain that since I've been following the steps in this MSDN link: https://msdn.microsoft.com/de-de/VBA/Word-VBA/articles/document-exportasfixedformat-method-word to the letter. Do you have any idea what I could try to get past the error?
但是在执行时,我总是会得到错误80070057。我在谷歌上搜索了错误代码,它说“无效论述”,但我无法解释,因为我一直遵循这个MSDN链接中的步骤:https://msdn.microsoft.com/de- de/vba/articles/document -exportasfixedformat-method-word。你知道我能做些什么来克服这个错误吗?
Workarounds I've tried: Using SaveAs and SaveAs2 don't work either, they always ignore the Format I require (wdFormatPDF) and save the document as docx. The only thing that works to some extent is to set ActivePrinter as print2pdf and then use the PrinOut method, but it gives me a printer dialog, which I don't want.
我尝试过的解决方案:使用SaveAs和SaveAs2也不起作用,它们总是忽略我需要的格式(wdFormatPDF),并将文档保存为docx。在某种程度上,唯一起作用的是将ActivePrinter设置为print2pdf,然后使用PrinOut方法,但是它给了我一个打印机对话框,这是我不想要的。
1 个解决方案