This is specific to VBA, not any other OOPL. In VBA, the objects in the hierarchy as in your example are called "qualifications." In VBA, if you leave out the qualification, VBA has rules about what it will use as the default.
In the example you gave, you did not "skip" objects in the hierarchy, even though it looks that way. ActiveCell defaults to Application.ActiveCell. ActiveWindow is a different type of object that also has cells, and it just so happens that ActiveWindow also has an active cell, and by their definitions they will be the same. Technically the two don't mean the same thing, but they end up pointing to the same object. It's like giving someone a street address vs. saying, "Go to the second house on the left." They both get you to the same place but they mean something different.
Here's another example. If you use the expression
you have omitted the qualification for the Worksheet. It can have two different defaults, depending on where the code is. If the code is in a module for a Sheet object, it will default to that sheet.
If it is in a Module, then it will default to ActiveWorksheet.
To be able to "skip" qualifications, you have to really understand what each qualification does and what the defaults are. That is why it is a best practice to make all qualifications explicit. If you give your code to someone else to maintain, or even if you look at your own code 6 months after you write it, it may be unclear what was intended, and this is a real nightmare if there is a bug.
Bookmarks