Code
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF FileName:="sales.pdf" Quality:=xlQualityStandard DisplayFileAfterPublish:=True
converted to C#
Can someone please oblige this request?ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF FileName:="sales.pdf" Quality:=xlQualityStandard DisplayFileAfterPublish:=True
converted to C#
Can someone please oblige this request?Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Feb 16, 2013, 1:12 AM EST
If you don't want to hard-code a path, then it's possible to save files to system folders using the Environment.SpecialFolder enumeration:
http://msdn.microsoft.com/en-gb/library/system.environment.specialfolder(VS.100).aspx
VulpesRank #55 · 29.2K reputationPosted Feb 15, 2013, 4:56 AM EST
The ExportAsFixedFormat method doesn't have a parameter called DisplayFileAfterPublish (not in Excel 2007 anyway) so I've assumed that it must be OpenAfterPublish that's intended.
richard smithRank #8,268 · 225 reputationPosted Feb 15, 2013, 6:18 AM EST
On the very first argument
(Type: XLFixedFormatType.xlTypePDF,
I get a compile error of The name 'XLFixedFormatType' does not exist in the current context.
However on top of that, I am now receiving multiple Errors like:
'Workbook' is an ambiguous reference between 'Microsoft.Office.Interop.Excel.WOrkbook' and 'Microsoft.Office.Tools.Excel.Workbook'
And the 2nd compile error of Cannot find the interop type that matches the embedded interop type 'Microsoft.Office.Tools.Excel.Worksheet' Are you missing an assembly reference?
I am going to remove the Assembly Extension, as that will remove my compile errors. Did I do that incorrectly?
VulpesRank #55 · 29.2K reputationPosted Feb 15, 2013, 6:49 AM EST
However, if you don't need to use tools then, yes, I'd remove the assembly reference as Office interop is complicated enough!
richard smithRank #8,268 · 225 reputationPosted Feb 15, 2013, 9:01 AM EST
richard smithRank #8,268 · 225 reputationPosted Feb 15, 2013, 9:07 AM EST
richard smithRank #8,268 · 225 reputationPosted Feb 15, 2013, 10:57 AM EST