VBA 中的关键字可以引用 with-block 变量吗?

Can a with-block variable be referenced by a keyword in VBA?

with-block变量有关键字吗?例如,如果该关键字是 This,则以下代码将起作用:

With New myType
    .DoSomething
    DoSomethingElse "abc", This, 123
End With

恐怕不存在这样的关键字。在 Visual Basic 中,我为此编写了一个扩展方法 .Myself。在 VBA 中,我不知道任何解决方案。当然你可以使用局部变量。

Set a = New mytype
a.DoSomething
DoSomethingElse "abc", a, 123

您可以将以下 Function 添加到您的 MyType class

Public Function This() As MyType
    Set This = Me
End Function

以便您的主要代码可以如下利用它:

With New MyType
    .DoSomething
    DoSomethingElse "abc", .This, 123

End With