PDA

View Full Version : [SOLVED:] Report Generator Fix - Run-time error '1004': Doc not saved



Merckling
04-07-2017, 05:45 AM
Hi everyone, new to the forums, as well as VBA. Trying to fix a Run-time error '1004' when I attempt to generate a report in Excel.
After the error, clicking debug highlights this line of code:

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strPDFFileName

Is there an obvious mistake I'm making here or will I need to include some more information?

Appreciate the help.

mdmackillop
04-07-2017, 09:37 AM
There is a "Document not saved" error if that PDF file is open on the PC.

Merckling
04-07-2017, 10:05 AM
File wasn't open, but already existed. All I had to do was change the filename, lol very silly but thank you.

mdmackillop
04-07-2017, 10:40 AM
You can use the Kill command to delete an existing file before creating a new version.