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!

Path and Filename from Active Workbook.

Status
Not open for further replies.

HelloLloyd

Technical User
Dec 27, 2002
18
US
I am wanting to get the path and filename of the active workbook without having to prompt the user to enter it. For example, I have file D:\Documents and Settings\John Doe\Desktop\Test open. I want to know if VBA can harvest that info using the ActiveWorkbook tag, or do I have to prompt the user to enter it. Thanks for all the help.
 
pick a remote cell in your workbook

and type =cell("filename")


then in your code ....

my_file_name=sheets("your_sheet").range("your_cell_ref")


 
Thanks. That works great. Do you know if there is a way I can use the WorksheetFunction code so I don't have to put the reference physically in the workbook. It's not vital, but would be nice. Thanks again.
 
Sub test()
dim p as string
dim n as string
dim file_path as string


p = ActiveWorkbook.Path
n = ActiveWorkbook.Name

file_path = p + "\" + n

msgbox(file_path)

End Sub
 
Awesome! Thanks so much for the help!!! I have a general question that you might can answer for me. I really would like to learn more VBA, but I can't find any good resources. How did you learn VBA, and do you recommend any books, etc. I've had programming experience, but I'm just really starting with VBA. Thanks for all the help!
 
Check places like borders books or barnes and noble...

You can also gain alot of know how by just running the macro recorder, going through some steps in excel and viewing the code that excel generates.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top