Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Jimmy,
GetObject is used to get a reference to an existing running instance of Excel. It will fail and return Nothing if there is no running instance of Excel. If there is more than one instance running, you have no control over which instance to which you will get a reference. Perhaps code like the following will work: Dim XL As Excel.Application Dim WB As Excel.Workbook On Error Resume Next Set XL = GetObject(,"Excel.Application") If XL Is Nothing Then Set XL = CreateObject("Excel.Application") End If If Not XL.ActiveWorkbook Is Nothing Then Set WB = XL.ActiveWorkbook End If -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Jimmy" wrote in message ink.net... Then perhaps I shouldn't be running GetObject at all? I just need a reference (from Word VBA) to the active Excel document, without knowing its name. Is this possible? "Chip Pearson" wrote in message ... If you don't know the filename, you cannot control with instance of Excel GetObject is going to return. -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "joe" wrote in message ... If I run the following code and I have an open spreadsheet with existing sheets, I get another instance of Excel w/no sheets. How can I reference the active spreadsheet(w/o knowing the filename?) Dim oXL as object Dim xlWorksheet as object Set oXL = GetObject("", "Excel.Application") Set xlWorkSheet = oXL.Worksheets.Add *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it! |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
using the active cell as a reference in a function | Excel Worksheet Functions | |||
How to reference an active cell | New Users to Excel | |||
Active row cell reference | Excel Worksheet Functions | |||
Active Cell Reference | Excel Worksheet Functions | |||
Active Cell Copy And Paste Sheet to Sheet | New Users to Excel |