When accessing current workbook:
use ThisWorkBook method
Debug.Print ActiveWorkbook.FullName
When accessing Any open workbook:
use Workbooks("name")
Debug.Print Workbooks("test.xlsx").FullName
Please note: above example will throw script out of range error if workbook is not opened or you mention full path of workbook.
Avoid using ActiveWorkbook and Workbooks(index)
use ThisWorkBook method
Debug.Print ActiveWorkbook.FullName
When accessing Any open workbook:
use Workbooks("name")
Debug.Print Workbooks("test.xlsx").FullName
Please note: above example will throw script out of range error if workbook is not opened or you mention full path of workbook.
Avoid using ActiveWorkbook and Workbooks(index)
No comments:
Post a Comment