GetObject command

GetObject command

Anonymous
Not applicable
215 Views
2 Replies
Message 1 of 3

GetObject command

Anonymous
Not applicable
I am trying to use the following command to retrieve the currently active
Excel workbook.
Set ExcelServer = GetObject(, "Excel.Application")
ExcelServer.WindowState = XlWindowState.xlMinimized

According to the help file: "If the pathname argument is omitted, GetObject
returns a currently active object of the specified type" I find that if I
have an instance of Excel running and I execute the command it returns an
empty excel window, but not the current workbook, which is what I want.

What am i missing?
0 Likes
216 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Getting the aplication doesn't necessarily get you the document. GetObject(,
"AutoCAD.Application") won't yield the active document in a running instance
of AutoCAD. See if you can use the ActiveWorkbook property to get your
document reference.

--
Visit AcadXtreme for a chance to win a copy of AutoCAD LT 2000
Contest ends 5/26/00
http://www.acadx.com

"John Wilde" wrote in message
news:ef1cfbe.-1@WebX.SaUCah8kaAW...
> I am trying to use the following command to retrieve the currently active
> Excel workbook.
> Set ExcelServer = GetObject(, "Excel.Application")
> ExcelServer.WindowState = XlWindowState.xlMinimized
>
> According to the help file: "If the pathname argument is omitted,
GetObject
> returns a currently active object of the specified type" I find that if I
> have an instance of Excel running and I execute the command it returns an
> empty excel window, but not the current workbook, which is what I want.
>
> What am i missing?
>
0 Likes
Message 3 of 3

Anonymous
Not applicable
This works for me

'Set oExcelBook = oExcelApp.Workbooks.Add
Set oExcelSheet = oExcelApp.ActiveWorkbook.Sheets("Sheet1")

Gary
0 Likes