cancel
Showing results for 
Search instead for 
Did you mean: 

Excel to PDF Utility

RyanMutya
Level 3
I am trying to create an object that will save the excel file to pdf. I am getting errors with the code that is releated Microsoft.Office.Interop.Excel but I already add the dll to the external references.
6 REPLIES 6

JustinBishop
Level 4
Do you have a PDF writer installed on your workstation? It may be easier to just have Excel use a PDF writer. You can download a free PDF application called ""CutePDF"".

RyanMutya
Level 3
and then excel will print the worksheet to pdf right?

Yes. ""Printing"" would simply allow you to save the file.

RyanMutya
Level 3
Hi scott, I have been following the source from this site since yesterday same that you provided: https://msdn.microsoft.com/en-us/library/bb407651%28v=office.12%29.aspx but it is giving me an error: - 'XlFixedFormatQuality' namespace could not be found, does not exist in the current context - Microsoft.Office.Interop.Excel.Workbook does not contain a definition for ""ExportAsFixedFormat"" I already added the Microsoft.Office.Interop.Excel.dll in the external references and also in the namespace imports. I am thinking that it has something to do Excel 12.0 Object Library but dont know on how to include or and where to get it. Thanks. Ryan

You could do this using a custom Code Stage in your MS Excel VBO. Something like this works: Dim wb as Object = GetWorkbook(handle,workbookname) Dim excel as Object = wb.Application excel.DisplayAlerts = False wb.ActiveSheet.ExportAsFixedFormat (Type:=0, Filename:= ""C:\Temp\MyTestPDF.pdf"", Quality:=0, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False) excel.DisplayAlerts = True Two values need to be hard-coded: Quality (0=standard), and the Type (0=PDF, 1=XPS). You pass in the Handle and the Workbook name (e.g. ""Test.xlsx"") to a new page in the MS Excel VBO called something like ""ExportToPDF"" and then call that in your Process. Hope that's useful. Chris McDermott.

Hi Chris,
In this example how do you make the Filename dynamic?  I have attempted to use this code based on a youtube video and it is not working.  I tried passing in a dynamic variable name for the FileName but am doing something wrong.

Thanks,

Jon



------------------------------
Jonathan Holstine
Systems Accountant
Interior Business Center
America/Denver
------------------------------