ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF FileName:="sales.pdf" Quality:=xlQualityStandard DisplayFileAfterPublish:=True
converted to C#
Can someone please oblige this request?Convert VBA to C#
I need this line of code:
VulpesPosted Feb 16, 2013, 6:12 AM
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
richard smithPosted Feb 15, 2013, 3:57 PM
richard smithPosted Feb 15, 2013, 2:07 PM
richard smithPosted Feb 15, 2013, 2:01 PM
VulpesPosted Feb 15, 2013, 11:49 AM
However, if you don't need to use tools then, yes, I'd remove the assembly reference as Office interop is complicated enough!
richard smithPosted Feb 15, 2013, 11:18 AM
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?
VulpesPosted Feb 15, 2013, 9:56 AM
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.