Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
GetObject()
#3
Not Solved
Retrieves an existing object with the specified ProgID, or creates a new one from a file.
object.GetObject(strPathname [,strProgID], [strPrefix])

The following VBScript code starts the application associated with the specified file (strPathname):
Code:
Dim MyObject As Object
Set MyObject = GetObject("C:\CAD\SCHEMA.CAD")
MyApp = MyObject.Application
Some applications allow you to activate part of a file. To do this, add an exclamation mark (!) 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 example, in a drawing application, a drawing stored in a file might have multiple layers. The following code activates a layer within a drawing file called SCHEMA.CAD:

Set LayerObject = GetObject("C:\CAD\SCHEMA.CAD!Layer3")

If you do not specify the object's class (strProgID), COM determines the application to start from the file name. Some files 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 may be part of the same file.

In the following VBScript code, the drawing application FIGMENT starts and opens the object DRAWING from within the file SAMPLE.DRW.
Code:
Dim MyObject As Object
Set MyObject = GetObject("C:\DRAWINGS\SAMPLE.DRW", "FIGMENT.DRAWING")
Reply


Messages In This Thread
GetObject() - by Sheikh - 10-13-2015, 11:05 PM
RE: GetObject() - by tigerliew - 10-24-2015, 08:32 AM
RE: GetObject() - by vinod123 - 11-03-2015, 03:22 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  GETOBJECT mvstesting 1 5,858 04-09-2010, 08:17 PM
Last Post: supputuri

Forum Jump:


Users browsing this thread: 1 Guest(s)