Hi, I have a VBA procedure that loops through each file in a directory and does the following:
1. Opens the file
2. Selects 2 sheets
3. Exports those sheets to a PDF
Excel is crashing during this process at random. I.e., one time it can crash after 6 PDF files created, and another after 10 files etc.
The interesting thing is that Excel is crashing without hanging at all! The window just immediately closes and excel is closed! (Never saw this before)
Another thing to note, if I run the code in debug mode, and step through each file one at a time, then it works perfectly.
I.e., I put a break point right before the line to export to PDF. Each time it hit the break point, I just pressed F5 to continue to the next file. Excel got through all the files without crashing.
Can it be a speed issue? I.e., creating too many files to export at the same time?
If anyone has any idea what this can be, please let me know
Thanks,
David
This is the line of code that I use to export:
1. Opens the file
2. Selects 2 sheets
3. Exports those sheets to a PDF
Excel is crashing during this process at random. I.e., one time it can crash after 6 PDF files created, and another after 10 files etc.
The interesting thing is that Excel is crashing without hanging at all! The window just immediately closes and excel is closed! (Never saw this before)
Another thing to note, if I run the code in debug mode, and step through each file one at a time, then it works perfectly.
I.e., I put a break point right before the line to export to PDF. Each time it hit the break point, I just pressed F5 to continue to the next file. Excel got through all the files without crashing.
Can it be a speed issue? I.e., creating too many files to export at the same time?
If anyone has any idea what this can be, please let me know
Thanks,
David
This is the line of code that I use to export:
Code:
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
fileName:=fileName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False