Consider the following code:
Public Sub VBACompilerIsMad()
Dim Ap As Application
Dim Wb As Workbook
Dim Ws As Worksheet
Debug.Print Ap.XXX ' No compile error
Debug.Print Wb.XXX ' No compile error
Debug.Print Ws.XXX ' Compile error
End Sub
When I compile this, I get a compiler error for referring to an inexisting member of Worksheet
. However, if I comment out the last line, there is no compiler error, even though neither Application
nor Workbook
have a method or property XXX
. It is as if I declared Ap
and Wb
as Object
variables.
Why does the compiler treat Application
/ Workbook
differently from Worksheet
?
Are there any other classes like this, that the compiler seems to treat as if they were Object
?