Retrieve an Automation object (assumes there is a current instance of the object)

      Set objObject = Wscript.GetObject(strPathname [,strProgID] ], [strPrefix])


   strPathname : The pathname of the file containing the object to retrieve. 

   strProgID   : The program identifier (ProgID) of the object. 

   strPrefix   : A prefix for subroutine names (optional)
                 e.g. if strPrefix is "MYOBJ_" and the object fires an event
                 named "OnBegin," WSH calls the subroutine "MYOBJ_OnBegin" 

   objObject is an Automation object. 

GetObject is a wscript method.


Open a copy of the Excel application:

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True
objExcel.Cells(1, 1).Value = "Some demonstration text"

Open an Excel file:

Set objExcelFile = GetObject("C:\demo\example.xlsx")
WScript.Echo objExcelFile.Name

“When I take action I'm not going to fire a $2 million missile at a $10 empty tent and hit a camel in the butt. It's going to be decisive” ~ George W Bush, 2001


.CreateObject - Create a WSH automation object.
.ConnectObject - Connect to a COM object.
.DisconnectObject - Disconnect from a COM object.

Copyright © 1999-2023
Some rights reserved