The Great SrH
Board Regular
- Joined
- Jan 16, 2015
- Messages
- 179
Hi all,
I have a "macro-enabled" excel document i've created. I'm looking to add the following code to save part as the document as PDF.
I want the document to save in the same location as the Excel file. An alternative code I'd like if anyone has, is for the user to have the "Save As" box appear so they can name the file themselves.
However, I keep getting a runtime error stating:
"Run-Time Error '1004' Document not saved. The document may be open or an error may have been encountered."
When i try to export the document as PDF (non VBA), I also get a similar error.
Any suggestions on how to fix this?
Thanks
I have a "macro-enabled" excel document i've created. I'm looking to add the following code to save part as the document as PDF.
Code:
Private Sub CommandButton4_Click()
Application.ScreenUpdating = False
Worksheets("request").Unprotect ("bacon")
Sheets("request").Range("A1:I45").ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=Range("S8").Value _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
Worksheets("request").Protect ("bacon")
Application.ScreenUpdating = True
End Sub
I want the document to save in the same location as the Excel file. An alternative code I'd like if anyone has, is for the user to have the "Save As" box appear so they can name the file themselves.
However, I keep getting a runtime error stating:
"Run-Time Error '1004' Document not saved. The document may be open or an error may have been encountered."
When i try to export the document as PDF (non VBA), I also get a similar error.
Any suggestions on how to fix this?
Thanks
Last edited: