Link to home
Start Free TrialLog in
Avatar of dgd1212
dgd1212

asked on

Change ThisWorkBook.Path direction

The code snippet below directs a new workbook to c:\tmp

If Dir(ThisWorkbook.Path & "\" & "new.xlsx") = "" Then
        xBook.SaveAs Filename:=ThisWorkbook.Path & "\" & ThisWorkbook.Name & "_" & Format(Now(), "yyyymmdd_hhnnss") & ".xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    Else
        xBook.SaveAs Filename:=ThisWorkbook.Path & "\" & "new.xlsx", FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
    End If

How would this be altered to go to D:\My Documents (windows environment)

And the equivalent in the MAC OS. I don't use MAC and not sure if there is a common directory for docs.

Thanks in advance for any suggestions
SOLUTION
Avatar of Martin Liss
Martin Liss
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dgd1212
dgd1212

ASKER

maybe I am misunderstanding the solution. once the second Workbook is created it should be filed into "My Documents". I'm making the assumption that "My Documents" is the same for XP, and windows 7/8. Not sure how the code should be written to accomplish. Thanks