Hi
I am newbie to applescript… I need to implement the applescript code into my cocoa project.
I need to convert the MS Word , MS Powerpoint and MS Excel files into PDF… How can i do this using applescript?
Can anyone help me out?
Thank u in advance
if you’re using leopard not sl you can you this if you install cups-pdf printer (do a google search).
(*
Create PDFs from Word and other files
Credit to macadmin at macstuff.beachdogs.org for the printer utility code.
*)
global the_printer
--Choose Folder and sort view
set CFolder to (choose folder with prompt "What folder would you like to work in?")
tell application "Finder"
activate
open CFolder
get name of Finder window 1
set winRef to Finder window 1
select winRef
set current view of winRef to list view
set sort column of list view options of Finder window 1 to modification date column
delay 0.5
close winRef
end tell
-- change default printer
tell application "Printer Setup Utility"
set the_printer to the current printer
set the_name to the name of the_printer
if the_name is not "CUPS-PDF" then
set the_count to the count of printers
repeat with x from 1 to the_count
if the name of printer x is "CUPS-PDF" then
set the current printer to printer x
end if
end repeat
end if
quit
end tell
-- choose files in folder to be printed to pdf
tell application "AppleScript Editor"
activate
set cFiles to (choose file with prompt "What file(s) would you like to convert to PDF. You may select multiple files." default location CFolder with multiple selections allowed)
tell application "Finder"
activate
repeat with i from 1 to number of items in cFiles
set this_item to item i of cFiles
print this_item
end repeat
--change printer back to previous setting and open "Cups folder"
tell application "Printer Setup Utility"
set the current printer to the_printer
quit
end tell
tell application "Finder"
activate
make new Finder window to folder "cups-pdf" of (path to desktop)
end tell
end tell
end tell