Save as PDF from Excel 2008

I am working with Excel 2008 (ie, Mac)
I have a worksheet set up to print a report as follows:
I enter a unique ID number into A1
info in the print area uses vlookup to reflect accurate data

Then I Print - > save as pdf

The problem is that I have to do this over and over and over. I don’t mind entering their numbers, but, I hate that I have to use the mouse for the PDF->Print to PDF portion.

I need a key combination to get me to the window for entering the file name. Or, ideally, an icon on my Excel toolbar that will get me directly to: Save as PDF

Several months ago, I tried setting up the keystrokes and writing a script with automator, but I got sidetracked and I don’t think it ever worked. I don’t know scripting, or automator, and the script doesn’t work.

tell application “Microsoft Excel”
set mySheet to worksheet “Sheet1” of active workbook
set N_ame to the value of cell “A2” of mySheet
tell application “System Events”
keystroke “p” using command down
delay 1
keystroke “p” using {option down, command down}
delay 1
keystroke “d” using command down
delay 1
keystroke “” & N_ame & “”
keystroke return
end tell
end tell

Do you have any suggestions what needs to be done to make this work?
Thank you!

I don’t know if 2008 allows you to customize the ribbon with a SaveAs button as 2004 does. This script will show the SaveAs dialog box.
I don’t know how to assign it to a key combination.

tell application "Microsoft Excel"
	show (get dialog dialog save as)
end tell

Thank you, it’s short and sweet, and i hadn’t thought of saving the file as a pdf; I was printing to pdf… yours is shorter, I think.

But I have to run it without touching the mouse, and I want the contents of cell A3 transferred to the file name…

Have you downloaded the applescript referenece from the MicroSoft website.

The Print to File option isn’t supported for Excel 2004, I don’t know if they included it in 2008.

I didn’t know about the reference
I downloaded it

It’s 462 pages which is overwhelming for someone who doesn’t know anything about applescript and automator and is just trying to do something that seems very simple.

I’ll try to search in it for something that seems appropriate.

Thank you

EDIT: Either there’s nothing helpful in the document or it’s there but I don’t know how to implement it.

I would look to see if the Print to File (?) argument of the Print Out command is enabled in 2008.

You can save to PDF using the script below.
With regard to

if you save the script below and place it into your /users/yourusername/Documents/Microsoft User Data/Excel Script Menu Items folder, next time you open Excel, in the Menu bar you should see the script icon on the far right, if you click the script icon you’ll see your script to execute.
Hope this helps,

set ptd to path to desktop as string

tell application "Microsoft Excel"
	set filename to the value of cell "A2" as text
	save active workbook in (ptd & filename & ".pdf") as PDF file format
end tell