Solved

Change ThisWorkBook.Path direction

Posted on 2013-01-30
3
379 Views
Last Modified: 2013-02-02
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
0
Comment
Question by:dgd1212
3 Comments
 
LVL 46

Assisted Solution

by:Martin Liss
Martin Liss earned 100 total points
ID: 38837918
On the MAC the directory is 'Documents'.
0
 
LVL 2

Accepted Solution

by:
junholee earned 400 total points
ID: 38838344
0
 

Author Comment

by:dgd1212
ID: 38847207
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
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now