different version of excel - script for getting a workbook open in a specific version
different version of excel - script for getting a workbook open in a specific version
- Subject: different version of excel - script for getting a workbook open in a specific version
- From: Selena Brewington <email@hidden>
- Date: Mon, 20 Jun 2005 11:35:42 -0700
Maybe this will help someone else out there.
I've been struggling to write something in Applescript to get a
workbook opened up in Excel 98. I've never written anything in
Applescript before. I'm running OSX (Panther). We're trying to
migrate some folks off of OS9.
The workbook has a number of macros in it and formerly ran in Excel 4.
I figured that I could check which version of Excel was running (Excel
98 is seen as version 8.0, Office X is 10.0, Office 2004 is 11.0) and
then exit it somewhat gracefully. I created an alias to the real
workbook on the local drive and pointed the script at it. I could
never get it to work! Excel 98 would start, but the script would
either fail silently, or open the file up in a more recent version.
Also, the 'open workbook' commands didn't seem to work for Excel 98.
Today, I got my script to work by changing the "Open With" attribute in
the file info for the workbook I'm dealing with. I have 3 or 4
different versions of Excel installed at any time, and just didn't
realize how important that "Open With" field is. Before changing that
field, the Finder would open the workbook in whatever version of Excel
was the 'default' at that time - regardless of what version of Excel
was already running.
Anyway, the script is below. There's nothing earth-shattering about
it, but I hope it saves someone a few minutes (or in my case hours and
days) of frustration.
-selena
tell application "Finder"
if process "Microsoft Excel" exists then
tell application "Microsoft Excel"
with transaction
set theVersion to version as string
set AppleScript's text item delimiters to {"."}
set mainVersion to (text item 1 of theVersion) as integer
set AppleScript's text item delimiters to {""}
if mainVersion > 10 then
tell application "Microsoft Excel"
activate
with transaction
quit saving ask
delay 5
end transaction
end tell
tell application "Finder"
activate
select file "Microsoft Excel" of folder "Microsoft Office 98" of
folder "Applications (Mac OS 9)" of startup disk
open selection
select file "Path" of folder "To" of folder "Your File" startup
disk
open selection
end tell
tell application "Microsoft Excel"
activate
end tell
else
tell application "Finder"
activate
select file "Path" of folder "To" of folder "Your File" of
startup disk
open selection
end tell
end if
end transaction
end tell
else
tell application "Finder"
activate
select file "Microsoft Excel" of folder "Microsoft Office 98" of
folder "Applications (Mac OS 9)" of startup disk
open selection
select file "Path" of folder "To" of folder "Your File" of startup
disk
open selection
end tell
end if
end tell
_______________________________________________
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