[英]Difference between Thisworkbook.name and Activeworkbook.name in VBA
Is there any difference between Thisworkbook and ActiveWorkbook. Thisworkbook和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不起作用的ThisWorkbook
Activeworkbook.name
is used to get the name of the active workbook from n different number of opened workbooks. Activeworkbook.name
用于从n个不同数量的已打开工作簿中获取活动工作簿的名称。
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. Thisworkbook.name
用于获取在该工作簿的模块中编写或存储代码的工作簿的名称。
Eg 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 例如,如果您正在编写工作簿A
的模块或工作表中的代码,那么Thisworkbook.name
将返回A
无论哪个是活动工作簿
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.