Apply this enhanced version which is able to restore original settings.
--
--[SCRIPT touchIworkPlists]
(*
2009/09/12 now may restore original settings.
*)
property applyToIwork09 : true
(* true = apply to iWork '09
false = apply to iWork '08 *)
--=====
on run
if applyToIwork09 then
set iworkNum to 9
(* for Pages '09 *)
set pagesStrings to {"Microsoft Word document", "Microsoft Word 97 - 2004 document"}
(* for Numbers '09 *)
set numbersStrings to {"Microsoft Excel workbook", "Microsoft Excel 97-2004 workbook", "Microsoft Excel macro-enabled workbook"}
else
set iworkNum to 8
(* for Pages '08 *)
set pagesStrings to {"SLDocumentTypeMSWord"}
(* for Numbers '08 *)
set numbersStrings to {"LSDocumentTypeExcel"}
end if
set {btn1, btn2, btn3} to {"Cancel", "Reset original", "Save Office docs"}
set what to display dialog "What to do ?" buttons {btn1, btn2, btn3}
set what to button returned of what
if what is btn1 then error number -128
if what is btn3 then
set what to "Editor"
else
set what to "Viewer"
end if
my touchPlist("Pages", iworkNum, pagesStrings, what)
my touchPlist("Numbers", iworkNum, numbersStrings, what)
end run
--=====
on touchPlist(theApp, num, lStrings, theMode)
set thePlist to (path to applications folder as text) & "iWork '0" & num & ":" & theApp & ".app:Contents:Info.plist"
tell application "System Events"
set InfoRecord to (get value of property list file thePlist)
end tell
set CFBundleDocumentTypes to get |CFBundleDocumentTypes| of InfoRecord
repeat with i from 1 to count of CFBundleDocumentTypes
if |CFBundleTypeName| of item i of CFBundleDocumentTypes is in lStrings then
set |CFBundleTypeRole| of item i of CFBundleDocumentTypes to theMode
end if
end repeat
set |CFBundleDocumentTypes| of InfoRecord to CFBundleDocumentTypes
tell application "System Events"
set value of property list file thePlist to InfoRecord
end tell
end touchPlist
--=====
--[/SCRIPT]
--
Yvan KOENIG (VALLAURIS, France) Sunday, September 13, 2009 12:18:18