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!

Getting Filename 1

Status
Not open for further replies.

rpg121

Programmer
Mar 14, 2001
89
US
I need to be able to get the filename of the current open excel workbook and put it into a string variable. I can't have the path in that string, just the filename. What is the best way to do this?
 
Code:
Dim flName As String
flName=ActiveWorkbook.Name
 
Wow, was I ever looking in the wrong place. Thanks a lot for your help.
 
What are you doing with the workbook name?

If you just want to refer to the workbook in your code, then consider setting a workbook or worksheet variable instead.
Code:
Dim wb As Workbook
Dim ws As Worksheet
Set wb=ActiveWorkbook
Set ws=ActiveSheet
'Your code can then use statements like:
wb.Worksheets.Add    'Adds a worksheet
ws.Range("A1")="New value"    'Sets a cell to a new value
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top