ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   vba, get filename of this workbook (https://www.excelbanter.com/excel-discussion-misc-queries/181756-vba-get-filename-workbook.html)

md[_2_]

vba, get filename of this workbook
 
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

md[_2_]

vba, get filename of this workbook
 
On Mar 28, 8:46 pm, md wrote:
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)

Barb Reinhardt

vba, get filename of this workbook
 
You may want to consider using ThisWorkbook if the workbook with the macro is
not the active workbook.
--
HTH,
Barb Reinhardt



"md" wrote:

On Mar 28, 8:46 pm, md wrote:
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)


Dave Peterson

vba, get filename of this 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



md wrote:

On Mar 28, 8:46 pm, md wrote:
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)


--

Dave Peterson


All times are GMT +1. The time now is 04:04 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com