热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

抛出异常80070057-MSWordExportAsFixedFormat(..)throwsException80070057

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 个解决方案

#1


1  

The problem is most likely caused by your use of late binding with named arguments (which requires early binding). Instead of:

这个问题很可能是由于您使用了带有命名参数的后期绑定(这需要早期绑定)而导致的。而不是:

wApp.ActiveDocument.ExportAsFixedFormat OutputFileName :="tst1.pdf", _ ExportFormat := wdExportFormatPDF, UseISO19005_1 := True

wApp.ActiveDocument。ExportAsFixedFormat OutputFileName:= " tst1。= wdExportFormatPDF, UseISO19005_1:= True

try:

试一试:

wApp.ActiveDocument.ExportAsFixedFormat "tst1.pdf", 17, , , , , , , , , , , , True

wApp.ActiveDocument。tst1 ExportAsFixedFormat”。pdf", 17,,,,,,,,,,真


推荐阅读
author-avatar
mobiledu2502869373
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有