Excel VBA error

Posted on 2014-04-26
Last Modified: 2014-04-26
Sub TestPdf()
    ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, FileName:="\\pmcfs\groups\Accounting\Physician Stats\PhysRpts\Testsc"
End Sub

the above sub routine is giving me the error in Excel 2007:

Invalid Procedure Call or Argument

How can I fix this?


Question by:GPSPOW
  • 3
  • 2
LVL 35

Expert Comment

ID: 40025058
Export to PDF was introduced in Office 2010. I'm afraid you're using VBA code you picked up meant for Office 2010+.

Author Comment

ID: 40025062
With all the different version out there now.  Is there a backwards compatability fix to save an Excel sheet as a PDF if the user is using Excel 2003 or 2007?
LVL 35

Expert Comment

ID: 40025067
No, a function will not magically appear in older programs. If this magic happened, no person would ever buy new programs either.

Now you're backup solution might be to check if the version is 2007 or older, then check if PDF creator is installed, then use alternate code to generate it.
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.


Author Comment

ID: 40025114
I've requested that this question be deleted for the following reason:

Since there is not backwards compatibility between Excel 2010 and v. 2003 & 2007 to create a PDF without external programming, I am dropping the question and will try to figure out another way to do what I need.


LVL 27

Accepted Solution

MacroShadow earned 500 total points
ID: 40025115
You can use the code you posted in 2007 after you install the SaveAsPDF addin from Microsoft.

Author Closing Comment

ID: 40025194
Ill try it.



Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Problem to line 23 53
How to bypass VBA Project password 5 49
List Box Entries Excel 2010 5 29
Excel Split Employee Name into Lname Fname Mname 3 15
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question