ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Getting objects other than 'Excel.Application using GetObject() (https://www.excelbanter.com/excel-programming/431792-getting-objects-other-than-excel-application-using-getobject.html)

urkec

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

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.


--
urkec



All times are GMT +1. The time now is 10:02 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com