Applescript for opening a workbook

Hi all. Used to develop scripts, but it’s been a long time. I am stumped. I have this:

tell application “Microsoft Excel”
activate
set default file path to “/Volumes/data/LogosAdmin/TechData/Tech Documents”
open workbook workbook file name “DHCP Clients.xlsx”
copy range range “B:E” of sheet “DHCP Clients.xls” of workbook “DHCP Clients.xlsx”
end tell

Why will this not work? I also tried the full path starting with the actual hard drive volume name. I tried using colons instead of forward slashes. I tried everything. I copied the file name AND the path from the Get Info dialog, so it’s correct and the file is there. This is an AFP share by the way. What is wrong with this??

The error I get is:
error “Microsoft Excel got an error: Can’t continue open workbook.” number -1708

Bob

Model: Macbook Pro 17"
AppleScript: The latest for Snow Leopard
Browser: Firefox 8.0.1
Operating System: Mac OS X (10.7)

Hi,

just


tell application "Microsoft Excel"
	activate
	open "data:LogosAdmin:TechData:Tech Documents:DHCP Clients.xlsx"
	copy range range "B:E" of sheet "DHCP Clients.xls" of active workbook
end tell

Hi thanks for the reply. I consulted another use list for Livecode (Hypercard on steroids very cool) and someone suggested this:

tell application “Microsoft Excel”
set myPath to POSIX file “/volumes/data/LogosAdmin/TechData/Tech Documents/DHCP Clients.xlsx”
if not (exists workbook “DHCP Clients.xlsx”) then
open workbook workbook file name myPath
end if
copy range range “B:E” of sheet “DHCP Clients.xls” of workbook “DHCP Clients.xlsx”
end tell

Now what I need is a way to mount a network share if it is not mounted yet.

I am making a procurve scanner which will query a series of procurve switches and then trace a mac address through them to locate the port that mac address shows up on. I will then query an excel spreadsheet of known mac-address/IP address/device names to tell me if it is a known device on my network. We get rogue devices all the time and I have to find them.

The bulk of the coding will be done in Livecode, which is capable of sending scripts to Applescript, but they have no telnet API, although they can shell into the current OS and send commands.

Bob

An afp volume can be mounted with


if "data" is not in "/bin/ls /Volumes" then
	mount volume "afp://" & serverName & "/data" as user name user_name with password pass_word
end if

In Excel it’s not necessary to check for the opened workbook.
If the workbook is already open nothing happens.
I recommend also to use the colon separated HFS path instead of the POSIX path with coercion