Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











Method:  WScript.GetObject

WScript.GetObject (strPathName [,strProgID] [,strSubPrefix])

The GetObject method loads the specified file into the associated application and returns a reference to the instance of the application object. If an application object of the appropriate type already exists, the specified file will be loaded into the existing instance, otherwise a new instance will be created. If the specified file can be handled by multiple applications, the ProgID of the desired application can be specified. If an empty string is specified for the filename, a ProgID must be specified, and this method will behave the same as a call to CreateObject.

The GetObject method can also be used to register the current script as an event-handler for the returned object by specifying a non-empty value for strSubPrefix. See the documentation on the ConnectObject and CreateObject methods for examples of handling events in your script.

The use of the GetObject method is demonstrated in the following VBScript code which loads the file "C:\test.doc" into the associated application (Microsoft Word) and returns a reference to the instance of the Word Document object. It then makes sure that the containing Word Application is visible, and prints the name of the document just opened.

Code:
Set objWord = WScript.GetObject("C:\test.doc")
objWord.Application.Visible = True
WScript.Echo "You just opened", objWord.Name


Output:
You just opened Test.doc

 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information