WScript.GetObject() (Method)

Access an already existing object rather than creating a new one.

Availability:

JScript - 3.0
Property/method value type:WScript object
JavaScript syntax:WSHWScript.GetObject(aPath)
WSHWScript.GetObject(aPath, aProgID)
WSHWScript.GetObject(aPath, aProgID, aPrefix)
Argument list:aPathThe path to an already existing document
aProgIDAn application programme ID
aPrefixA hook into the event model

You can use this method to access an object that you know already exists without needing to create a fresh instance. An example of the difference is that CreateObject() is used to manufacture new documents via the application while GetObject() is used to access existing documents.

Given the object that encapsulates the document, since it is a WScript object, you can access its Application property to control the owning application.

See also:WScript.Application