Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个截图来显示一个表格
Form1.Show //shortcut is ctrl+Q
如果我激活另一个工作簿并按 ctrl+Q - 表单也会出现 ,我希望它仅在其书籍处于活动状态时出现。 我试过:
If ThisWorkbook = ActiveWorkbook Then Form1.Show
或者
If ActiveWorkbook = ThisWorkbook Then Form1.Show
并得到语法错误。
引用 .name 怎么样?
If ThisWorkbook.Name = ActiveWorkbook.Name Then MsgBox "Is Active" End If
即使 Excel 2013 也不会同时打开两个同名的工作簿。
ActiveWorkbook 和 Thisworkbook 是对象;因此,要比较它们,您必须使用is而不是=.
is
=
If Thisworkbook is ActhiveWorkbook then Form1.Show