martywal
asked on
Saving Worksheet to PDF in Excel
Hi Experts,
I'm having an issue with trying to save worksheets as PDF's in Excel. My Script looks like this:
Sheets("ORF - Process Summary").Visible = True
Sheets("ORF - Process Summary").Select
Sheets("ORF - Process Summary").Copy
ActiveSheet.ExportAsFixedF ormat Type:=xlTypePDF, Filename:= _
"\\svrau570bsm01\" & Range("ORFraiseLAN").Value & "$\My Documents\Classification Tool\" & Range("CURRENTorf").Value & " Process TEST.pdf" _
, Quality:=xlQualityStandard , IncludeDocProperties:=Fals e, _
IgnorePrintAreas:=False, OpenAfterPublish:=True
ActiveWindow.Close
I think that just having selected the sheet should be sufficient before running the export. I'm currently getting a runtime error '1004': Method 'Range' of object '_Worksheet' Failed
(the code is attached to a button on the worksheet I'm trying to save as a pdf).
Ultimately I want to save a number of worksheets as PDF's
Any help appreciated
I'm having an issue with trying to save worksheets as PDF's in Excel. My Script looks like this:
Sheets("ORF - Process Summary").Visible = True
Sheets("ORF - Process Summary").Select
Sheets("ORF - Process Summary").Copy
ActiveSheet.ExportAsFixedF
"\\svrau570bsm01\" & Range("ORFraiseLAN").Value
, Quality:=xlQualityStandard
IgnorePrintAreas:=False, OpenAfterPublish:=True
ActiveWindow.Close
I think that just having selected the sheet should be sufficient before running the export. I'm currently getting a runtime error '1004': Method 'Range' of object '_Worksheet' Failed
(the code is attached to a button on the worksheet I'm trying to save as a pdf).
Ultimately I want to save a number of worksheets as PDF's
Any help appreciated
You can use this code to verify that your ranges are "available":
Function isNameRngExist(myRng As String) As Boolean
On Error Resume Next
isNameRngExist = Len(ThisWorkbook.Names(The Name).Name ) <> 0
End Function
If not, you may need to fully qualify them.
Function isNameRngExist(myRng As String) As Boolean
On Error Resume Next
isNameRngExist = Len(ThisWorkbook.Names(The
End Function
If not, you may need to fully qualify them.
ASKER
Hi guys,
Sorry not been on this for the last few days.
Thanks for your input!
In terms the function, if I just add that to a module that should work when the error pops up, right?
I'm wondering if stopping the script from opening the PDF may fix the issue.
Sorry not been on this for the last few days.
Thanks for your input!
In terms the function, if I just add that to a module that should work when the error pops up, right?
I'm wondering if stopping the script from opening the PDF may fix the issue.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hi experts.
Sorry again for the lack of traction on this.
Indeed it looks like I'd stepped out of where I needed to be to save the pdf.
Appears fixed now.
I'll close in next day or two
Thanks for your help.
Martywal
Sorry again for the lack of traction on this.
Indeed it looks like I'd stepped out of where I needed to be to save the pdf.
Appears fixed now.
I'll close in next day or two
Thanks for your help.
Martywal
Are your named ranges correct and at this stage of the code available?
Regards