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

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
718
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

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,170
Office Version
  1. 2016
Platform
  1. Windows
Some people solved after closing down other running programs
Some solved repairing the MS Office.
Some just due to bad code

Hard to say
 

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
718
Office Version
  1. 365
Platform
  1. Windows
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
 

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
718
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

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

Zot

Well-known Member
Joined
Nov 26, 2020
Messages
1,170
Office Version
  1. 2016
Platform
  1. Windows
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.
 

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
14,052
Office Version
  1. 365
  2. 2010
Platform
  1. Windows
  2. Mobile

ADVERTISEMENT

The are people reported intermittent crash with 265 which is I think same as 2019.
365 is distinctly not the same as 2019
 

jimrward

Well-known Member
Joined
Feb 24, 2003
Messages
1,784
Office Version
  1. 2016
  2. 2013
  3. 2011
  4. 2010
  5. 2007
Platform
  1. Windows
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
 

willow1985

Well-known Member
Joined
Jul 24, 2019
Messages
718
Office Version
  1. 365
Platform
  1. Windows
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 😊
 

Watch MrExcel Video

Forum statistics

Threads
1,129,791
Messages
5,638,340
Members
417,021
Latest member
moon miner

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
Top