vba, get filename of this workbook

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
 
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

ActiveWorkbook.Path + '\' + ActiveWorkbook.Name (that was easy)
 
B

Barb Reinhardt

You may want to consider using ThisWorkbook if the workbook with the macro is
not the active workbook.
 
D

Dave Peterson

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
 
Top