Convert Excel to PDF

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
klneel
Newbie
Posts: 4
Joined: Tue Jul 21, 2015 5:01 pm

Convert Excel to PDF

Post by klneel » Tue Jul 21, 2015 5:14 pm

Hello,

I am new to Macro Scheduler and am looking for a way to convert an excel document to a pdf every morning, without having to be logged onto my computer. Is there any way that this can be done? If so I would love help on the code!

Another issue that I am running into is that the excel file has data from other excel files. In this case every time I open the document I get the pop-up window asking to update links. I want to be able to automate this, but unfortunately when I don't have the original source file open, I get stuck with a lot of #VALUE, so both excel files need to be open. Is there a fix to this?

Thank you
Last edited by klneel on Wed Jul 22, 2015 2:41 pm, edited 1 time in total.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Convert Excel to PDF

Post by JRL » Wed Jul 22, 2015 3:19 am

Does your version of Excel have .PDF as a "save as" option?

klneel
Newbie
Posts: 4
Joined: Tue Jul 21, 2015 5:01 pm

Re: Convert Excel to PDF

Post by klneel » Wed Jul 22, 2015 12:40 pm

JRL,

Do you mean the drop down save as tab? In that case yes.

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Convert Excel to PDF

Post by JRL » Wed Jul 22, 2015 8:51 pm

No guarantee this will be perfect for you but hopefully it will be close and give you some idea of a way to proceed.

Code: Select all

//Change these three lines to reflect your real file names.
Let>vPDFName=c:\path\vPDFFileName.pdf
Let>vFileMain=c:\path\ExcelFileName.xlsx
Let>vFileDependancy=c:\path\ExcelFileName.xlsx




ExtractFileName>vFileMain,vMain
ExtractFileExt>vFileMain,vExt
StringReplace>vMain,vExt,,vMain

ExtractFileName>vFileDependancy,vDependancy
ExtractFileExt>vFileDependancy,vExt
StringReplace>vDependancy,vExt,,vDependancy


ExecuteFile>vFileMain
ExecuteFile>vFileDependancy

WaitWindowOpen>%vDependancy%*
WaitReady>0

WaitWindowOpen>%vMain%*
WaitReady>0

SetFocus>%vMain%*
Wait>1
Press Alt
Send>fa
Release Alt

Wait>1
Send>b

Wait>1
Press Tab

Wait>1
Send>p

Wait>1
Press shift
Press Tab
Release shift

Send>vPDFName
Wait>1

Press Enter

Let>WW_TIMEOUT=5
WaitWindowOpen>Confirm Save As*
Wait>1
Send>y
Wait>1

Let>WW_TIMEOUT=0
WaitWindowOpen>Publishing...
Wait>1
WaitWindowClosed>Publishing...
Wait>1

SetFocus>%vDependancy%*
Wait>1


Press Alt
Send>f
Wait>1
Send>x
Release Alt

SetFocus>%vMain%*
Wait>3

Press Alt
Send>f
Wait>1
Send>x
Release Alt

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts