• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Print Word document to PDF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Print Word document to PDF


  • Subject: Re: Print Word document to PDF
  • From: Michael Ghilissen <email@hidden>
  • Date: Sat, 16 Jun 2007 07:29:48 -0400

Here is my version of a Word to PDF script:

Here are points points to consider:

1/ If you use the built-in print-to-PDF feature of Mac OS X for an MS Word document with multiple sections, you will get multiple PDFs, one per section. Preview will generate a single PDF file with the correct page layouts.  And that does the trick as Preview's GUI can be scripted! So my script has two sections: the first one, in Word, that gets the document and the file's name and then calls Preview; the second one, in Preview, that formats the pdf document and saves it.
2/ You need to include delays long enough for the script to keep up with the pace (machine's speed and document's size) - or the script will crash, so experiment with changing the delays to a comfortable level - YMMV.
3/ The script is obviously dependent on the versions of OS X, Microsoft Word and Preview.

And here is the script:

tell application "Microsoft Word" to activate
tell application "System Events"
tell application process "Microsoft Word"
click menu item "Print..." of menu "File" of menu bar item "File" of menu bar 1
delay 0.5
click button 4 of UI element 5 of window 1
end tell
end tell
--
delay 1
--
tell application "Preview" to activate
tell application "System Events"
tell application process "Preview"
click menu item "Print…" of menu 1 of menu bar item "File" of menu bar 1
delay 0.5
click at position of UI element 1 of UI element 6 of UI element 4 of sheet 1 of window 1
delay 0.2
key code {125, 49}
delay 1
-- if new file name is needed, enter the pdf name into the Save dialog's text field
set value of text field 1 of window 1 to "test2.pdf"
delay 0.5
-- use Control-d to set the desktop as the destination
keystroke "d" using command down
delay 0.5
click button "Save" of window "Save"
delay 0.2
end tell
end tell

Good luck,

Michael Ghilissen
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Print Word document to PDF
      • From: Peter Baxter <email@hidden>
References: 
 >Print word document to PDF (From: Peter Baxter <email@hidden>)
 >Re: Print word document to PDF (From: Jeremy Sellors <email@hidden>)

  • Prev by Date: Re: Print word document to PDF
  • Next by Date: Scope for Beginners
  • Previous by thread: Re: Print word document to PDF
  • Next by thread: Re: Print Word document to PDF
  • Index(es):
    • Date
    • Thread