Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel ExportasFixedformat在900次运行期间抛出错误1004一到五次_Excel_Vba - Fatal编程技术网

Excel ExportasFixedformat在900次运行期间抛出错误1004一到五次

Excel ExportasFixedformat在900次运行期间抛出错误1004一到五次,excel,vba,Excel,Vba,Excel VBA宏 错误代码: Worksheets("Rapport").Range("print").ExportAsFixedFormat Type:=xlTypePDF, Filename:=filename 抛出错误1004,但在900+循环的6-7小时运行期间仅抛出1到5次 我点击debug,然后点击play按钮,它运行正常,并按预期导出文件。我什么都不改变 我已尝试放置应用程序。请在导出前等待2秒钟。没有帮助。这似乎有效,我的宏循环了90

Excel VBA宏

错误代码:

Worksheets("Rapport").Range("print").ExportAsFixedFormat Type:=xlTypePDF, Filename:=filename
抛出错误1004,但在900+循环的6-7小时运行期间仅抛出1到5次

我点击debug,然后点击play按钮,它运行正常,并按预期导出文件。我什么都不改变


我已尝试放置应用程序。请在导出前等待2秒钟。没有帮助。

这似乎有效,我的宏循环了901次,并且没有因为上一个错误而停止过一次。谢谢你的建议

myerrorhandler:
Application.Wait (Now + TimeValue("0:00:03"))
On Error GoTo myerrorhandler
Worksheets("Rapport").Range("print").ExportAsFixedFormat Type:=xlTypePDF, Filename:=filnavn

可能尝试将导出包装在错误处理程序中,并在第一次出错时重试(可能在短暂等待后)