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:
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.