Search code examples
excelvbavariablesdropbox

VBA obtaining Dropbox file path for multiple users (Mac and PC)


I created an excel file housed within a specific Dropbox folder that uses a macro to append a date and time stamp to certain tabs of the file and then saves it to that same folder.

On a PC, the path is something like

C:\Users\MyName\Dropbox\Daily History\

while on a MAC it is something like

Macintosh HD: Users: meadowbrook: Documents:

The only thing I can think of to make it dynamic is somehow using CELL("filename") and dynamically storing it as a variable. Is there a way to just save as to the directory the file is in without needing to specify the path in VBA?


Solution

  • Use

    Application.ActiveWorkbook.Path 
    

    for just the path itself (without the workbook name) or

    Application.ActiveWorkbook.FullName 
    

    for the path with the workbook name