Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Save As Workbook to current Directory 1

Status
Not open for further replies.

vestax22

Programmer
Jun 18, 2003
139
CA
Hi, I want to have a button that will contain code to save the active workbook to the current directory with a new name (A Save AS) Does anybody know what function would return the current directory?


Thx, Lots of questions today I know and I appreciate a lot

P.S. Using Excel 2000
 
Hey, none of these answers give me the path of the avtive workbook.


Application.path gives the default save path
curdir() gives the directory for Excel

Any other Ideas?
 
activeworkbook.path returns the directory of where the program is run from, not the default save path.
 
applicatin.path will give yout he directory where you are running the main excel exe. But activeworkbook.path will return the path of where you are running the excel file from(the active workbook).

That should work Vestax22
 
Thx Jooky68 but I had found the solution before reading this post. Since you led me to the answer ...
 
The right reference is the path property of the workbook from which the program is running. This workbook is called ThisWorkbook, probably after the key work "this" in C++. Similarly, in Word, use ThisDocument.

ThisWorkBook.path + "yourfilename.xls"

It took me quit a while to figure this out. Before that, I have to use a global variable set in the Document_Open event.
 
Hi VBOnly,

Only vestax22 can say what the right reference is. In the original question (s)he asked for the current directory but it seems that what was wanted was the path of the active workbook. The workbook about to be saved may be, but is not necessarily, ThisWorkbook and, indeed, it quite probably is and was in this case, but again is not necessarily, the Active Workbook. It seems a solution to the problem in hand was found anyway.

Enjoy,
Tony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top