VORK中的Thisworkbook.name和Activeworkbook.name之间的区别 [英] Difference between Thisworkbook.name and Activeworkbook.name in VBA

查看:852
本文介绍了VORK中的Thisworkbook.name和Activeworkbook.name之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



示例代码:

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

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆