cancel
Showing results for 
Search instead for 
Did you mean: 

Saving Excel file as PDF

JonathanHolstin
Level 5

Hello,
I have found a few videos on this topic and attempted to follow them but not having any luck.  Does anyone have any links to easy walk-throughs on this or is anyone willing to chat with me on how to accomplish this task.

Thanks,

Jon



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

Hi, Jon,

create a new action in MS Excel VBO and put there codes stage with following code. Assuming that you know what else to do. If you do not know just ask.

Dim wb as Object = GetWorkbook(handle,workbookname)
Dim excel as Object = wb.Application

Dim fileformat As Integer = 0

excel.DisplayAlerts = False
excel.ActiveSheet.ExportAsFixedFormat(fileformat, filename)
excel.DisplayAlerts = True

Regards,

------------------------------
Zdeněk Kabátek
Head of Professional Services
NEOOPS
http://www.neoops.com/
Europe/Prague
------------------------------

Hi Zdenek,
Thanks for the reply.  I have attached what I did, I'm going to change my code to yours and see if that works.

Does the filename you are passing need to end with .PDF or .xlsx?

If you have a chance to look at my screenshots and let me know what I'm messing up it would be greatly appreciated!

Jon

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

Hi Zdenek,
I think I got it working using your code.  Two quick follow-ups.  When I dump the collection into excel and save in this format.  1) It doesn't expand the columns to show entire cell, is there a way to make this happen?  

2) Is there a way to save PDF in a landscape format vs portrait?  Or do you have a better way to dump a collection into a PDF document that looks good?

Thanks so much!!

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

Hi Zdenek,
I figured it all out.  Thank you for your initial assist.

Jon


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

Glad I could help, Jon :).

------------------------------
Zdeněk Kabátek
Head of Professional Services
NEOOPS
http://www.neoops.com/
Europe/Prague
------------------------------

Hey im getting error in this can you plz help me out in solving it.
i am pasting the error which i am getting:
Internal : Could not execute code stage because exception thrown by code stage: Save Workbook As took more than 0 secs.
in action in timeout i have provided 10 sec.but still getting error.

------------------------------
Kumari Yadav
------------------------------

Hi, Kumari,

can you paste the code you have in your code stage?

Regards,

------------------------------
Zdeněk Kabátek
Head of Professional Services
NEOOPS
http://www.neoops.com/
Europe/Prague
------------------------------

newworkbookname = ExecWithTimeout(Timeout, "Save Workbook As",
Function()
Dim wb as Object = GetWorkbook(handle,workbookname)
Dim excel as Object = wb.Application

excel.DisplayAlerts = False
wb.ActiveSheet.ExportAsFixedFormat (Type:=0, Filename:=(filename), Quality:=0, IncludeDroperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False)

excel.DisplayAlerts = True

Return wb.Name
End Function)

This is the code i am using nd yesterday actually i did some mistake after correcting that still its not resolved getting the following error:
Internal : Could not execute code stage because exception thrown by code stage: Exception from HRESULT: 0x800A03EC
Please reply as soon as possible

------------------------------
Kumari Yadav
------------------------------

and one more thing i want to ask you that after applying this code it will just convert the excel into pdf or it will save it also at some path .
Actually i am applying this action under one loop and need to save this and then use it later . please guide me on this also , how can we save it.
Thanks in advance.

------------------------------
Kumari Yadav
------------------------------