Help with VBA Run-time error '7': Out of memory when creating PDF

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
871
Office Version
  1. 365
Platform
  1. Windows
I have the following code, and it has worked before but today I am getting this out of memory error and I don't know how to fix it.

VBA Code:
Sub SavePDFopen()
'
' SavePDFopen Macro
'
Dim Path As String
Dim filename As String

Path = Sheets("CI Form Open").Range("T1")
filename = Sheets("CI Form Open").Range("T2")

ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename & ".pdf", Quality:=xlQualityStandard, _
  IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True
'
'
End Sub

Any help would be greatly appreciated.

Thank you

Carla
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
Some people solved after closing down other running programs
Some solved repairing the MS Office.
Some just due to bad code

Hard to say
 
Upvote 0
I have shut down everything, restarted the computer etc. Still get the error.
It used to work fine but for some reason I am getting the error now and I do not know why.

The error is on this line:

VBA Code:
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, filename:=Path & filename & ".pdf", Quality:=xlQualityStandard, _
  IncludeDocProperties:=False, IgnorePrintAreas:=False, OpenAfterPublish:=True

Any help would be appreciated.

Thank you
 
Upvote 0
I deleted the code, saved the workbook and rewrote the code exactly the same way. Now it works again.

So to anyone having this error, try that. Hopefully it keeps working this time.
 
Upvote 0
Solution
The are people reported intermittent crash with 265 which is I think same as 2019.

Try repair MSOffice. I remember seeing a registry tweak using regedit from MS support but I cannot find it now. The guy was complaining about intermittent error on program that was running fine for long time before upgrading.
 
Upvote 0
Just out of interest and as a test what happens if you leave out includedocproperties and ignoreprintareas try leaving them out one by one
also as a final test change the openafterpublish to false i recall years ago having issues with openafterpublish depending on whether acrobat viewer or full version was installed and how it opened either in browser or actual acrobat program
 
Upvote 0
It is currently working but I do run it weekly. I will play around with it again next week to see what happens and will let you know.

Thank you jimrward, and everyone who was involved with assisting me with this, much appreciated ?
 
Upvote 0

Forum statistics

Threads
1,213,494
Messages
6,113,981
Members
448,538
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top