Hi!

    This has many different explanations to look at. You may want the class 
version or a file name...
        Bruce

GetObject:
Returns a reference to an object provided by a COM component.
Namespace:
Microsoft.VisualBasic
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)
Click to collapse. Double-click to collapse all.
C#
C++
F#
VB
Copy
[HostProtectionAttribute(SecurityAction.LinkDemand, Resources = 
HostProtectionResource.ExternalProcessMgmt)]
[SecurityPermissionAttribute(SecurityAction.Demand, Flags = 
SecurityPermissionFlag.UnmanagedCode)]
public static
 Object GetObject(
string
 PathName,
string
 Class
)
Parameters
PathName
Type:
System.String
Optional. String. The full path and name of the file containing the object to 
retrieve.
If
PathName is omitted, Class is required.
Class
Type:
System.String
Required if PathName is not supplied. String
. A string representing the class of the object. The
Class argument has the following syntax and parts:
appname.objecttype
[1|1] Parameter
[1|2] Description
[2|1] appname
[2|2] Required. String. The name of the application providing the object.
[3|1] objecttype
[3|2] Required. String. The type or class of object to create.
Return Value
Type:
System.Object
Returns a reference to an object provided by a COM component.
Click to collapse. Double-click to collapse all.
Exception
Condition
Exception
No object of the specified class type exists.
FileNotFoundException
No object with the specified path and file name exists.
Click to collapse. Double-click to collapse all.
Use the GetObject
 function to load an instance of a COM component from a file. The following 
example
illustrates this.
VB
Copy
Dim CADObject As Object
CADObject = GetObject("C:\CAD\schema.cad")
When this code runs, the application associated with the specified PathName
 is started and the object in the specified file is activated.
Default Cases
If PathName is a zero-length string (""), GetObject
 returns a new object instance of the specified class type. If the
PathName argument is omitted, GetObject
 returns a currently active object of the class type specified in
Class. If no object of the specified type exists, an error occurs.
Accessing a Subobject
Some applications allow you to activate a subobject associated with a file. To 
do
this, 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.
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.
VB
Copy
layerObject = GetObject("C:\CAD\schema.cad!Layer3")
Specifying a Class
If you do not specify the object's Class
, Automation determines the application to start and the object to activate, 
based
on the file name you provide. Some files, however, can 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. The following example illustrates this.
VB
Copy
Dim drawObj As Object
drawObj = GetObject("C:\Drawings\sample.drw", "Figment.Drawing")
In the preceding example, Figment is the name of a drawing application and 
Drawing
 is one of the object types it supports.
Using the Object
Once an object is activated, you refer to it in code using the object variable 
you
declared. In the preceding example, you access properties and methods of the new
object using the object variable
drawObj. The following example illustrates this.
VB
Copy
drawObj.Line(9, 90)
drawObj.InsertText(9, 100, "Hello, world."
)
drawObj.SaveAs(
"C:\Drawings\sample.drw")
Note
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 loaded. If there is no current instance, and you do not 
want
the object started with a file loaded, use the
CreateObject
 function.
If an object has registered itself as an ActiveX single-instance object, only 
one
instance of the object is created, no matter how many times
CreateObject
 is called. 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. You 
cannot
use
GetObject to obtain a reference to a class created with Visual Basic.
Security note
Security Note
The GetObject
 function requires unmanaged code permission, which might affect its execution 
in
partial-trust situations. For more information, see
SecurityPermission
 and
Code Access Permissions
.
Note
Note
The
HostProtectionAttribute
 attribute applied to this type or member has the following
Resources
 property value:
Resources. The
HostProtectionAttribute
 does not affect desktop applications (which are typically started by 
double-clicking
an icon, typing a command, or entering a URL in a browser). For more 
information,
see the
HostProtectionAttribute
 class or
SQL Server Programming and Host Protection Attributes
.

  Sent: Tuesday, October 07, 2014 7:22 AM
  Subject: GetObject syntax / function


  I am having issues reproducing a GetObject() command I am using in a JAWS 
script to work in WindowEyes. In JAWS  GetObject(R”eflection.Session”). Note 
that in JAWS this takes just one argument. After invoking this command I can 
act directly with the scriptable objects of the current session. In VBS with 
WindowEyes the GetObject requires two parameters, where the second parameter 
appears to be equivalent to the parameter that JAWS uses.


  If I use a null string for the first parameter then Reflection creates a new 
hidden window. If I use the path of the Reflections settings file then I get a 
new session to the host. If I leave the first parameter completely blank, I get 
back an ActiveX error.  What am I missing here?


  Thanks in advance for any hints.Best wishes,


  Jonathan







---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com

Reply via email to