This project has moved and is read-only. For the latest updates, please go here.

Save Excel worksheet to PDF

Apr 12, 2015 at 7:56 PM
Edited Apr 12, 2015 at 7:58 PM
Hi all,
I'm trying to convert a VBA Add-In using Visual Studio 2010. The following command throws an exception when used in either way:
Excel.Enums.XlFixedFormatType.xlTypePDF, _
spath, Excel.Enums.XlFixedFormatQuality.xlQualityStandard,_
True, False, Type.Missing, Type.Missing, True, Type.Missing)
as well as
Type:=Excel.Enums.XlFixedFormatType.xlTypePDF, _
Filename:=spath, _
Quality:=Excel.Enums.XlFixedFormatQuality.xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
From:=Type.Missing, To:=Type.Missing, OpenAfterPublish:=True, _
The error message (German language) says:
"Fehler beim Methodenaufruf. Public Sub ExportAsFixedFormat(type As NetOffice.ExcelApi.Enums.XlFixedFormatType, filename As System.Object, quality As System.Object, includeDocProperties As System.Object, ignorePrintAreas As System.Object, from As System.Object, to As System.Object, openAfterPublish As System.Object, fixedFormatExtClassPtr As System.Object) kann nicht mit diesen Argumenten aufgerufen werden:
Das Argument wurde für den Parameter from nicht angegeben.
Das Argument wurde für den Parameter to nicht angegeben.
Das Argument wurde für den Parameter fixedFormatExtClassPtr nicht angegeben.
The variable 'spath' is a valid string object which specifies the path and filename of the pdf to create.
Did I misunderstand anything or did I probably stumble into a bug in NetOffice?

Apr 12, 2015 at 11:21 PM
Hey Mick,
(its you? long time ago i talk with a german guy with same name)

I find a topic for the problem:

It seems to be this a printer issue. Make sure the spooler service is running and the Microsoft XPS Document Writer is installed.
If its not, you find some download links in the stackoverflow topic.

Apr 13, 2015 at 2:47 PM
Edited Apr 13, 2015 at 7:32 PM
Hi Sebastian,

yes I guess I'm that same thankful Mick :-) but I stay with the topic and in English here, so others won't get confused.

After having a close look at the ressources / links you provided, I doubt that it's the solution in my case (and most others). These solutions consider Office 2007, which can be extended with an Add-In to export as PDF file (obviously it's become part of Excel after this 2007 version).

Using Excel 2010, which has the ability of pdf-export (and mail) already built-in, I never had any problems with the VBA macro(s) doing exactly the same thing. I also didn't change anything in the setup of my development machine. So it would be quite unlikely that it's a printer issue. EDIT: This afternoon I switched back to the VBA add-in to check, and it still works perfectly without any downloads or changes in the setup.

Can you please have another close look at the code? It seems that "Type.Missing" isn't enough for the parameters to work properly.