VORK中的Thisworkbook.name和Activeworkbook.name之间的区别 [英] Difference between Thisworkbook.name and Activeworkbook.name in VBA
问题描述
示例代码:
Sub workbook_name()
MsgBox Thisworkbook.name
End Sub
Sub active_name()
MsgBox Activeworkbook.name
End Sub
两者都将返回相同的输出,
有没有其他的情况,我们必须特别使用ActiveWorkbook不工作的ThisWorkbook
Activeworkbook.name
用于从n个不同数量的打开的工作簿中获取活动工作簿的名称。
Thisworkbook.name
用于获取代码写入或存储在该工作簿模块中的工作簿的名称。
例如,如果您在工作簿的模块或工作表中编写代码 A
然后 thisworkbook.name
将返回 A
无论哪个是活动工作簿
Is there any difference between Thisworkbook and ActiveWorkbook.
Example code :
Sub workbook_name()
MsgBox Thisworkbook.name
End Sub
Sub active_name()
MsgBox Activeworkbook.name
End Sub
Both will return the same output,
Is there any other instances where we have to use particularly ThisWorkbook where ActiveWorkbook doesn't work
Activeworkbook.name
is used to get the name of the active workbook from n different number of opened workbooks.
Thisworkbook.name
is used to get the name of the workbook in which the code is written or stored in the module of that workbook.
E.g if you are writing the code in the module or sheet of workbook A
then Thisworkbook.name
will return A
no matter which is the activeworkbook
这篇关于VORK中的Thisworkbook.name和Activeworkbook.name之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!