VBA for Directory path in Excel 2011 for Mac?

TheMooch

New Member
Joined
Jan 10, 2007
Messages
25
Hi guys and gals,

Here's a question for you. I've got a spreadsheet that I use at work that has some big macros in it. I'm trying to work on it at home, but my Mac is having some issues with the macros. Specifically on the portion that looks for the path:

Code:
 If Worksheets("Main").Range("B25") = "" Then
        sPath = "C:\"
        Else
    sPath = Worksheets("Main").Range("B25")
    End If
 
  s = CurDir
  ChDrive sPath
  ChDir sPath
  fName = Application.GetOpenFilename

I'd LOVE to make this where it works in both Mac and Windows although 99.9999% of the time it only runs on Windows, so it's not a HUGE deal. The problem here is that Mac doesn't have a C:\ and entries like \Users\me, /Users/me, and Users:Me: don't work.

Ideas?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
One way might be to check which path separator the application is using. For example...

Code:
If Application.PathSeparator = ":" Then
    strPath = "Macintosh HD:"
Else
    strPath = "C:\"
End If
 
Upvote 0
I had thought to do something like that, but the reality is that it would only be for me and not worth the time to do since this file is meant to be run on corporat windows machines. I'm just hoping to find a generic way to code it so that it's "platform independent" so that i can work on it on my Mac at home and then have it work on the windows machines as normal.

It's really not that big a deal. I'll just have to work on it at work is all. :)
 
Upvote 0
i have similiar problem with path in vba on mac. on windows7 office2007 works perfect but on mac is not workable. i would like to there is some kind of converter that converts vba win code to vba mac code :)
if there's any help to this thread i would like to ask for help for my post :)
 
Upvote 0
May be you can use the Path property of the Workbook object and the Path property of the Application object...

Code:
strPath = ActiveWorkbook.Path & Application.PathSeparator

or

Code:
strPath = Workbooks("Book2.xls").Path & Application.PathSeparator

I don't have Excel 2011 for the Mac, but for Windows based versions, the following is also available...

Application.DefaultFilePath ---> Excel's default path

ChDir Application.PathSeparator ---> Changes the current directory to the root directory
 
Upvote 0

Forum statistics

Threads
1,224,566
Messages
6,179,555
Members
452,928
Latest member
101blockchains

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top