运行时错误:5,无效的过程调用或参数 [英] Runtime Error : 5, Invalid Procedure call or argument
本文介绍了运行时错误:5,无效的过程调用或参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经创建了一个用于将工作表模板导出为PDF的宏,如下所示:
ActiveWorkbook.Sheets(Sheet2) .ExportAsFixedFormat类型:= xlTypePDF,文件名:= _
/ pre>
ActiveWorkbook.Path& \Survey Report.pdf,_
质量:= xlQualityStandard,IncludeDocProperties:= True,IgnorePrintAreas _
:= False,OpenAfterPublish:= True
&尝试像谷歌建议的很多其他方式。
已尝试的链接:
- < a href =http://www.mrexcel.com/forum/excel-questions/608810-printing-multiple-worksheets-pdf-2.html =nofollow> http://www.mrexcel.com/论坛/ excel-questions / 608810-printing-multiple-worksheets-pdf-2.html
- http://www.mrexcel.com/forum/microsoft-access/385749-exportasfixedformat-error.html
- http://answers.microsoft.com/en-us/office/forum/office_2010-customize/error- 5-invalid-procedure-call-or-argument / 574c2c8f-7f2c-4644-9373-bbc14c8d3fd7?msgId = 4dbee3f3-ad28-4427-a50b-a3904b09ec1e
请他lp。
解决方案您的实际代码适用于我。但是尝试这个( TRIED AND TESTED )
Sub Sample()
ActiveWorkbook.Sheets (Sheet2)。激活
ActiveSheet.ExportAsFixedFormat _
类型:= xlTypePDF,_
文件名:= ActiveWorkbook.Path& \Survey Report.pdf,_
质量:= xlQualityStandard,_
IncludeDocProperties:= True,_
IgnorePrintAreas:= False,_
OpenAfterPublish:= True
End Sub
注意:
- 还希望
Sheet2
有其它东西可以打印,否则空白页将给你错误。
- 如果要从运行代码的工作簿中打印工作表,则可能需要将
ActiveWorkbook
更改为ThisWorkbook
并再次尝试...
I have created a macro for export the sheet template to PDF as below:
ActiveWorkbook.Sheets("Sheet2").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _ ActiveWorkbook.Path & "\Survey Report.pdf", _ Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _ :=False, OpenAfterPublish:=True
& tried it will lots of other way as Google suggested. but that makes no difference in error.
Links already tried :
- http://www.mrexcel.com/forum/excel-questions/608810-printing-multiple-worksheets-pdf-2.html
- http://www.mrexcel.com/forum/microsoft-access/385749-exportasfixedformat-error.html
- http://answers.microsoft.com/en-us/office/forum/office_2010-customize/error-5-invalid-procedure-call-or-argument/574c2c8f-7f2c-4644-9373-bbc14c8d3fd7?msgId=4dbee3f3-ad28-4427-a50b-a3904b09ec1e
Please help.
解决方案Your actual code works for me. However try this (TRIED AND TESTED)
Sub Sample() ActiveWorkbook.Sheets("Sheet2").Activate ActiveSheet.ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=ActiveWorkbook.Path & "\Survey Report.pdf", _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=True End Sub
Note:
- Also hope
Sheet2
has something in it to print else a blank sheet will give you the error.- If you want to print the sheet from the workbook where you are running the code then you might want to change
ActiveWorkbook
toThisWorkbook
and try again...
这篇关于运行时错误:5,无效的过程调用或参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文