PDA

View Full Version : How do I open a file on a windows server with a macro on a Mac OS X machine?



KevinHill
07-18-2005, 02:07 PM
The title pretty much says it all. I have a file on a OS X machine with a macro designed to open another file and read/write from it, but the target file is on a networked windows machine.The only way I have found to be able to do it is to mount the networked folder, and then treat that like a local folder.

This:

Workbooks.Open Filename:="smb:\\compname\folder\file.xls"

doesn't work. Once I mount the folder I can just do:


Workbooks.Open Filename:="folder:file.xls"

but I'd really hate to have to mount the folder every time I wanted to run the macro.

Any suggestions? Thanks

shades
07-18-2005, 06:49 PM
Howdy. I wonder if there might not be an AppleScript code that would achieve what you want.

BlueCactus
07-19-2005, 06:15 AM
Howdy. I wonder if there might not be an AppleScript code that would achieve what you want.
I would guess that there would be at least a way of mounting the folder using AppleScript from Office, but I'm way out of my territory with this one.

Going to Google and putting in AppleScript mounting network returns quite a few hits. One of those sites may have what you want. Some of the other threads in this forum have examples of using AppleScripts from Office if you need to know how to wrap up the deal.

shades
07-19-2005, 08:27 AM
Also, check out the Apple.com discussion groups. There is one for AppleScript. They may have something for you already.

KevinHill
07-19-2005, 09:11 AM
Ok, so now I seem to have problems with getting AppleScript to work with VBA. Here's my code:


Sub Update()
Dim script As String
script = _
"tell application ""finder""" & char(13) _
& "open location ""smb://username:pword@comp/folder""" & char(13) _
& "end tell"
MacScript (script)
End Sub

but whenever I run it I get the error "Sub or Function not defined" Is there a inclusion that I need to make? I'm running v.X if that helps.

KevinHill
07-19-2005, 10:21 AM
So, I'm still curious about how to get AppleScript working properly with VBA, but I just went ahead an made a workaround. Now the remote folder is just mounted upon startup on the Mac, allowing me to treat it like a local folder in the method described above.

BlueCactus
07-19-2005, 10:59 AM
I can't test it, but looking at your code try changing char(13) to chr(13)

BC

KevinHill
07-19-2005, 11:04 AM
Ahh, silly typos. That did it for me, thanks.