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
 

chrisnash

New Member
Joined
Jul 20, 2017
Messages
21
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:

chrisnash

New Member
Joined
Jul 20, 2017
Messages
21
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:

krishna_gopal_2

New Member
Joined
Jun 7, 2018
Messages
3
Tried reinstalling the Ms Office Suite.... Nothing works.... I tried some other simple macros.... Same error "5"....
 

chrisnash

New Member
Joined
Jul 20, 2017
Messages
21
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:

Forum statistics

Threads
1,082,573
Messages
5,366,372
Members
400,887
Latest member
tporeda

Some videos you may like

This Week's Hot Topics

Top