I would like a bit of clarification about why each class (or nearly each class) in VBA (when you scroll through Object Browser) has an Application
property.
MSDN says
When used without an object qualifier, this property returns an Application object that represents the Microsoft Excel application. When used with an object qualifier, this property returns an Application object that represents the creator of the specified object (you can use this property with an OLE Automation object to return the application of that object). Read-only.
The first sentence is pretty clear. Your hosting application used without a qualifier can be one of the MS Office products supporting VBA.
In Excel Debug.Print Application
= Microsoft Excel
In Word Debug.Print Application
= Microsoft Word
etc...
but...the second sentence is totally unclear to me... So I am thinking like no matter where you call .Application
from it will always return the host of an object...
- So, what is the point of each class in VBA to have an
Application
property?
PS. you can always call .Parent
=> .Parent
to go up the hierarchy... can't you? You can just call the Application
wit no qualifier to get that...
I can't even think of one SSCCE OLE scenario for this so I am sorry I am not providing an example. The Application
property (not to be confused with Application
class) is poorly documented this is why I am asking for someone with more experience to clarify this for me.
One (well, sort of) scenario, but not sure it even applies here could be using Interop for Office. Like, when you have an external application that opens two files ( one Excel, and one Word ) then by getting references to Range
s in both, you may be able to return Microsoft Excel
and Microsoft Word
.. but would this be even useful to anyone? hmm..Am I not understanding this entire concept?