当前位置: 动力学知识库 > 问答 > 编程问答 >

vba - PDFs stop generating from excel without explaination

问题描述:

My Excel 2007 macro generates 20 reports by replacing one cell with a look up value from a list, allowing a worksheet to update, and then exporting that worksheet to a PDF. After 8-10 are done the programme crashes, despite almost half having worked fine. The error message reads:

Run-time error '5': Invalid Procedure call or argument [Options: End or Debug or Help]

The PDF generating code is as follows:

ThisWorkbook.Sheets("Printing").Select

ActiveSheet.ExportAsFixedFormat _

Type:=xlTypePDF, _

fileName:=fileName, _

Quality:=xlQualityStandard, _

IncludeDocProperties:=True, _

IgnorePrintAreas:=False, _

OpenAfterPublish:=False

What could be the cause? Is RAM possible running out, and if so how can I reset it or clear it and keep the report generation going all the way to the end?

网友答案:

The problem was the lenght of the file name. I shortened my filenames and magically everything works. Thank-you to anyone who gave up time to think about the problem.

分享给朋友:
您可能感兴趣的文章:
随机阅读: