vba, get filename of this workbook

  • Thread starter Thread starter md
  • Start date Start date
M

md

I running a vba script inside a workbook. How do I get the complete
path to the workbook and name in which this script runs?

Thanks
 
I running a vba script inside a workbook. How do I get the complete
path to the workbook and name in which this script runs?

Thanks

ActiveWorkbook.Path + '\' + ActiveWorkbook.Name (that was easy)
 
You may want to consider using ThisWorkbook if the workbook with the macro is
not the active workbook.
 
And you may want to use & instead of +.

+'s are used to add numbers.
&'s are used to concatenate strings.

But excel's VBA is forgiving.

ActiveWorkbook.Path & "\" & ActiveWorkbook.Name

or even:
Activeworkbook.fullname
or
ThisWorkbook.fullname
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top