将工作表模板导出为PDF会生成运行时错误5:无效的过程调用或参数 [英] Exporting sheet template to PDF generates Runtime Error 5: Invalid Procedure call or argument

查看:409
本文介绍了将工作表模板导出为PDF会生成运行时错误5:无效的过程调用或参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经创建了一个宏,可以将工作表模板导出为PDF:

I have created a macro to export the sheet template to PDF:

ActiveWorkbook.Sheets("Sheet2").ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
  ActiveWorkbook.Path & "\Survey Report.pdf", _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
  :=False, OpenAfterPublish:=True

我用其他方法尝试过,但是在错误上没有区别.

I tried it other ways but it makes no difference in error.

链接已尝试:

  1. http://www .mrexcel.com/forum/excel-questions/608810-printing-multiple-worksheets-pdf-2.html
  2. http://www.mrexcel.com/forum /microsoft-access/385749-exportasfixedformat-error.html
  1. http://www.mrexcel.com/forum/excel-questions/608810-printing-multiple-worksheets-pdf-2.html
  2. http://www.mrexcel.com/forum/microsoft-access/385749-exportasfixedformat-error.html
  3. 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

推荐答案

您的实际代码对我有用.但是,请尝试此操作( TRIED AND TESTED )

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

注意:

  1. 也希望Sheet2可以打印一些内容,否则会出现空白页错误.
  2. 如果要从运行代码的工作簿中打印工作表,则可能需要将ActiveWorkbook更改为ThisWorkbook并重试...
  1. Also hope Sheet2 has something in it to print else a blank sheet will give you the error.
  2. If you want to print the sheet from the workbook where you are running the code then you might want to change ActiveWorkbook to ThisWorkbook and try again...

这篇关于将工作表模板导出为PDF会生成运行时错误5:无效的过程调用或参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆