RunTime Error 5

krishna_gopal_2

New Member
Joined
Jun 7, 2018
Messages
3
Hi All,

It seems an old question. I found so many posts regarding the same. But couldn't solve the error. I am trying to save my Active Sheet into a PDF using the following code. Initially, it worked fine. But recently it shows Run-time error 5. "Invalid Procedure Call & Argument". Please help me solve this.

Sub ExportToPDF1()ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Range("C3").Value, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
From:=1, _
To:=2, _
OpenAfterPublish:=True
End Sub

Thanks in Advance
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hi All,

It seems an old question. I found so many posts regarding the same. But couldn't solve the error. I am trying to save my Active Sheet into a PDF using the following code. Initially, it worked fine. But recently it shows Run-time error 5. "Invalid Procedure Call & Argument". Please help me solve this.



Thanks in Advance

I'm not getting any errors from the code.

Code:
Sub ExportToPDF1()
ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=Range("C3").Value, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
From:=1, _
To:=2, _
OpenAfterPublish:=True
End Sub

Can you attach a link to the actual file at all?
 
Last edited:
Upvote 0
Try this code otherwise:

Code:
Sub Save_to_PDF2()

ChDir "C:\Users\Smith\Desktop\"  'Change this location




Dim strXLName As String, strPDFName As String, intPos As Integer


strXLName = ActiveWorkbook.FullName
intPos = InStr(1, strXLName, ".")
strPDFName = Left(strXLName, intPos) & "pdf"


ActiveSheet.ExportAsFixedFormat _
Type:=xlTypePDF, _
filename:=strPDFName, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True


End Sub
 
Last edited:
Upvote 0
Can you send me a link so I can download your actual workbook that is showing the errors so I can have a look please.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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