Results 1 to 2 of 2

Thread: .getObject

  1. #1
    Join Date
    Dec 1969

    Default .getObject

    I can&#039t find any documentation on this topic. Can you explain it to me. Here is the code that I&#039m looking at:<BR><BR>set someObject=someObject.getObject(userNum, objDist.getDist(), StrDtDep, EndDtDep)

  2. #2
    Pat Murphy Guest

    Default RE: .getObject

    There are 2 responses here obtained from MSDN...Hope this helps...<BR><BR>Microsoft® Visual Basic® Scripting Edition<BR>GetObject Function Language Reference <BR>Version 2 See Also <BR><BR>Description<BR>Returns a reference to an Automation object from a file. <BR>Syntax<BR>GetObject([pathname] [, class])<BR>The GetObject function syntax has these parts:<BR><BR>Part Description <BR>pathname Optional; String. Full path and name of the file containing the object to retrieve. If pathname is omitted, class is required. <BR>class Optional; String. Class of the object. <BR><BR>The class argument uses the syntax appname.objectype and has these parts:<BR><BR>Part Description <BR>appname Required; String. Name of the application providing the object. <BR>objectype Required; String. Type or class of object to create. <BR><BR><BR><BR>Remarks<BR>Use the GetObject function to access an Automation object from a file and assign the object to an object variable. Use the Set statement to assign the object returned by GetObject to the object variable. For example: <BR>Dim CADObject<BR>Set CADObject = GetObject("C:CADSCHEMA.CAD")<BR><BR>When this code is executed, the application associated with the specified pathname is started and the object in the specified file is activated. If pathname is a zero-length string (""), GetObject returns a new object instance of the specified type. If the pathname argument is omitted, GetObject returns a currently active object of the specified type. If no object of the specified type exists, an error occurs.<BR>Some applications allow you to activate part of a file. Add an exclamation point (!) to the end of the file name and follow it with a string that identifies the part of the file you want to activate. For information on how to create this string, see the documentation for the application that created the object.<BR><BR>For example, in a drawing application you might have multiple layers to a drawing stored in a file. You could use the following code to activate a layer within a drawing called SCHEMA.CAD: <BR><BR>Set LayerObject = GetObject("C:CADSCHEMA.CAD!Layer3")<BR><BR>If you don&#039t specify the object&#039s class, Automation determines the application to start and the object to activate, based on the file name you provide. Some files, however, may support more than one class of object. For example, a drawing might support three different types of objects: an Application object, a Drawing object, and a Toolbar object, all of which are part of the same file. To specify which object in a file you want to activate, use the optional class argument. For example: <BR>Dim MyObject<BR>Set MyObject = GetObject("C:DRAWINGSSAMPLE.DRW", "FIGMENT.DRAWING")<BR><BR>In the preceding example, FIGMENT is the name of a drawing application and DRAWING is one of the object types it supports. Once an object is activated, you reference it in code using the object variable you defined. In the preceding example, you access properties and methods of the new object using the object variable MyObject. For example: <BR>MyObject.Line 9, 90<BR>MyObject.InsertText 9, 100, "Hello, world."<BR>MyObject.SaveAs "C:DRAWINGSSAMPLE.DRW"<BR><BR><BR>--------------------------------------------------------------------------------<BR> <BR>Note Use the GetObject function when there is a current instance of the object or if you want to create the object with a file already loaded. If there is no current instance, and you don&#039t want the object started with a file loaded, use the CreateObject function.<BR><BR>If an object has registered itself as a single-instance object, only one instance of the object is created, no matter how many times CreateObject is executed. With a single-instance object, GetObject always returns the same instance when called with the zero-length string ("") syntax, and it causes an error if the pathname argument is omitted. <BR><BR>--------------------------------------------------------------------------------<BR> <BR>OR<BR>IOleItemContainer::GetObject<BR>Return s a pointer to the object identified by the specified name. <BR><BR>HRESULT GetObject(<BR> LPOLESTR pszItem, //Pointer to name of the object requested<BR> DWORD dwSpeedNeeded, //Speed requirements on binding<BR> IBindCtx *pbc, //Pointer to bind context object to be used<BR> REFIID riid, //Reference to the identifier of the <BR> // interface pointer desired<BR> void **ppvObject //Address of output variable that receives <BR> // the interface pointer requested in riid<BR>);<BR> <BR>Parameters<BR>pszItem <BR>[in] Pointer to a zero-terminated string containing the container&#039s name for the requested object. For Win32 applications, the LPOLESTR type indicates a wide character string (two bytes per character); otherwise, the string has one byte per character. <BR>dwSpeedNeeded <BR>[in] Indicates approximately how long the caller will wait to get the object. The legal values for dwSpeedNeeded are taken from the enumeration BINDSPEED. For information on the BINDSPEED enumeration, see the "Data Structures" section. <BR>pbc <BR>[in] Pointer to the IBindCtx interface on the bind context object to be used in this binding operation. The bind context caches objects bound during the binding process, contains parameters that apply to all operations using the bind context, and provides the means by which the binding implementation should retrieve information about its environment. For more information, see IBindCtx. <BR>riid <BR>[in] Reference to the identifier of the interface pointer requested. <BR>ppvObject <BR>[out] Address of pointer variable that receives the interface pointer requested in riid. Upon successful return, *ppvObject contains the requested interface pointer to the object named by pszItem. When successful, the implementation must call IUnknown::AddRef on the *ppvObject; it is the caller&#039s responsibility to call IUnknown::Release. If an error occurs, the implementation sets *ppvObject to NULL. <BR>Return Values<BR>This method supports the standard return value E_OUTOFMEMORY, as well as the following: <BR><BR>S_OK <BR>The specified object was successfully returned. <BR>MK_E_EXCEEDEDDEADLINE <BR>The binding operation could not be completed within the time limit specified by the bind context&#039s BIND_OPTS structure, or with the speed indicated by the dwSpeedNeeded parameter. <BR>MK_E_NOOBJECT <BR>The parameter pszItem does not identify an object in this container. <BR>E_NOINTERFACE <BR>The requested interface was not available. <BR>Remarks<BR>The item moniker implementation of IMoniker::BindToObject calls this method, passing the name stored within the item moniker as the pszItem parameter. <BR><BR>Notes to Implementers<BR>Your implementation of IOleItemContainer::GetObject should first determine whether pszItem is a valid name for one of the container&#039s objects. If not, you should return MK_E_NOOBJECT.<BR><BR>If pszItem names an embedded or linked object, your implementation must check the value of the dwSpeedNeeded parameter. If the value is BINDSPEED_IMMEDIATE and the object is not yet loaded, you should return MK_E_EXCEEDEDDEADLINE. If the object is loaded, your implementation should determine whether the object is running (for example, by calling the OleIsRunning function). If it is not running and the dwSpeedNeeded value is BINDSPEED_MODERATE, your implementation should return MK_E_EXCEEDEDDEADLINE. If the object is not running and dwSpeedNeeded is BINDSPEED_INDEFINITE, your implementation should call the OleRun function to put the object in the running state. Then it can query the object for the requested interface. Note that it is important the object be running before you query for the interface.<BR><BR>If pszItem names a pseudo-object, your implementation can ignore the dwSpeedNeeded parameter because a pseudo-object is running whenever its container is running. In this case, your implementation can simply query for the requested interface.<BR><BR>If you want more specific information about the time limit than is given by dwSpeedNeeded, you can call IBindCtx::GetBindOptions on the pbc parameter to get the actual deadline parameter. <BR><BR>QuickInfo<BR> Windows NT: Use version 3.1 or later.<BR> Windows: Use Windows 95 or later.<BR> Windows CE: Unsupported.<BR> Header: Declared in oleidl.h.<BR><BR>See Also<BR>IMoniker::BindToObject, IBindCtx::GetBindOptions, OleIsRunning, OleRun <BR><BR><BR><BR> <BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts