Re: How to specify print file in MS Excel 2004?
Re: How to specify print file in MS Excel 2004?
- Subject: Re: How to specify print file in MS Excel 2004?
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 25 Jan 2005 12:03:29 -0800
On 1/25/05 11:16 AM, "Richard Rönnbäck" <email@hidden>
wrote:
> I am trying to print each sheet as a separate PDF file in Excel 2004, but I
> can't find how to set the name and location of the print file.
>
> Assuming that the Active printer is Adobe PDF (distiller) the code below
> will output the file, but is there any way to tell Excel where to put the
> file, and more importantly, how to name it?
>
> tell application "Microsoft Excel"
> tell workbook 1
> set theSheet to worksheet 1
> print out theSheet with print to file --active printer "Adobe_PDF"
> end tell
> end tell
Print to PDF is an important gap that hasn't been scripted for Office 2004.
My understanding is that it's really an OS function, and not part of the
object model inherited by the Office apps from its OLE Automation mode. It
won't be trivial to implement it, but I'm pretty hopeful it will be done
eventually - it's very much in demand.
Excel's 'print out' command does have that 'print to file' parameter you
found - pretty good. I don't have Adobe PDF printer to test, but I assume it
puts the file on the Desktop as the Print to PDF button does in the UI?
You can set the default location for _saving_ Excel files via
set default file path to "PB G5 HD
Panther:Users:berkowit:Documents:Microsoft User Data:Office Print Files:"
or wherever (use Unicode text, not alias). But I doubt that will help for
print to, since it doesn't in the UI. (As I said that's an OS dialog, not an
MS one).
I think you'll have to adopt a workaround of scripting the Finder to move
the file after it's created. You could rename it there too. (Alternatively,
saving the worksheet or workbook as an Excel file first would let you name
it, and likely it would keep the same name but with .pdf extension.)
Or you can use GUI scripting to call and click the Print to PDF screen, but
doing it as above and moving it in the Finder sounds better to me.
--
Paul Berkowitz
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden