I have a workbook which contains around 180 separate worksheets. Once a year, I need to make updates to all these worksheets and then save each worksheet as a .pdf file with the name of the worksheet and append the current year to the file name. Last year I managed to create a macro . . . which surprisingly did exactly what was needed, and generated a .pdf file of each worksheet, and saved them to a directory, which I specified.
This year, when I ran the same macro (modified to save the .pdf files to a different directory and to append the current year to the file name), the macro only ran 139 of the worksheets and then stopped with an error.
Run-time error '2147024809 (80070057)':
Expecting object to be local
I tried re-running the macro and the routine truncated at the exact same worksheet again. There doesn't seem to be anything unique or unusual about the 'terminal' worksheet that I can see. This is a puzzle, since the macro seemed to run through and save every worksheet, last year - and very little (of any significance) being changed from last year to this year. I will openly/freely acknowledge that what I know about VBA/macros - you could print on the head of a pin. I can include my very short macro (which I don't have with me today), but I thought I would post this today, to see if there's just some immediately obvious to someone in the listening audience . . . and a fix they would suggest.
This year, when I ran the same macro (modified to save the .pdf files to a different directory and to append the current year to the file name), the macro only ran 139 of the worksheets and then stopped with an error.
Run-time error '2147024809 (80070057)':
Expecting object to be local
I tried re-running the macro and the routine truncated at the exact same worksheet again. There doesn't seem to be anything unique or unusual about the 'terminal' worksheet that I can see. This is a puzzle, since the macro seemed to run through and save every worksheet, last year - and very little (of any significance) being changed from last year to this year. I will openly/freely acknowledge that what I know about VBA/macros - you could print on the head of a pin. I can include my very short macro (which I don't have with me today), but I thought I would post this today, to see if there's just some immediately obvious to someone in the listening audience . . . and a fix they would suggest.