Getting objects other than 'Excel.Application using GetObject()

U

urkec

I was looking at the GetObject() function help and have a question regarding
these samples:

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

and:

Dim MyObject As Object
Set MyObject = GetObject("C:\DRAWINGS\SAMPLE.DRW", "FIGMENT.DRAWING")


The first sample gets a regerence to an object called 'Layer3' contained in
schema.cad. Is anything similar possible for Excel? For Example:



Sub Test()

Set objWorkbook = GetObject("C:\Scripts\Test.xls")
Debug.Print objWorkbook.Name

'Set objSheet = GetObject("C:\Scripts\Test.xls!Sheet1")

End Sub


The first GetObject() call works, but the second call returns an 'invalid
syntax' error. Is it possible to use GetObject() to get reference to objects
other than Excel.Workbook (like Worksheet or any other)?

Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top