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?
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
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.