Search code examples
excelvbacallbyname

Why can you only use Call By Name on class modules?


I've encountered that in VBA for Excel you can only use CallByName on methods inside class modules, as this link indicates: http://support.microsoft.com/kb/186143 .

My question is why that is? I don't see why the same functionality could not be used outside classes.

I'm not sure if this is a specific VBA question or if the same thing holds for other programming languages.


Solution

  • Application.Run does the job for procedures in non-class modules (documentation).

    Why doesn't CallByName work for non-class procedures? It's just not within the scope of that statement.