WScript.GetObject

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

Syntax 
 Set objObject = Wscript.GetObject(strPathname [,strProgID] ], [strPrefix])
Arguments:
 strPathname : The pathname of the file containing the object to retrieve. 
 (required)
 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.

Examples

Open a copy of the Excel application:

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

Open an Excel file:

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

PowerShell equivalent, converting a String to a Double:

$num = "11.64"
$num = [double] $num

"Forget about being world famous, it's hard enough just getting the automatic doors at the supermarket to acknowledge our existence" ~ Douglas Coupland

Related:

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

(追記) (追記ここまで)
Copyright © 1999-2026 SS64.com
Some rights reserved

AltStyle によって変換されたページ (->オリジナル) /