Consulting

Results 1 to 8 of 8

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

  1. #1

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

    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

  2. #2
    Mac Moderator VBAX Expert shades's Avatar
    Joined
    May 2004
    Location
    Kansas City, USA
    Posts
    638
    Location
    Howdy. I wonder if there might not be an AppleScript code that would achieve what you want.

    Software: LibreOffice 3.3 on Mac OS X 10.6.5
    (retired Excel 2003 user, 3.28.2008 )
    Humanware: Older than dirt
    --------------------
    old, slow, and confused
    but at least I'm inconsistent!

    Rich

  3. #3
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    Quote Originally Posted by shades
    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.

  4. #4
    Mac Moderator VBAX Expert shades's Avatar
    Joined
    May 2004
    Location
    Kansas City, USA
    Posts
    638
    Location
    Also, check out the Apple.com discussion groups. There is one for AppleScript. They may have something for you already.

    Software: LibreOffice 3.3 on Mac OS X 10.6.5
    (retired Excel 2003 user, 3.28.2008 )
    Humanware: Older than dirt
    --------------------
    old, slow, and confused
    but at least I'm inconsistent!

    Rich

  5. #5
    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.

  6. #6
    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.

  7. #7
    VBAX Tutor
    Joined
    Mar 2005
    Posts
    268
    Location
    I can't test it, but looking at your code try changing char(13) to chr(13)

    BC

  8. #8
    Ahh, silly typos. That did it for me, thanks.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •