Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I need to manipulate an already open excel spreadsheet using VBScript. My
problem is that I can't seem to be able to get an object reference to excel if it's open already. I was able to open an excel workbook and add a sheet, but I wasn't able to connect to a spreadsheet it if it was already open. Anybody knows how to do it in VBScript? E.g: manually open MS Excel and type something in Sheet1. Then when you'd run this VBScript that I need, it would connect to Sheet1 and would display the content of it in a message box. Thanks a lot! JP |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
have you tried using GetObject instead of CreateObject?
Assuming you are NOT talking about Excel VBA when you say VBScript -- Regards, Tom Ogilvy "JP" wrote in message ... I need to manipulate an already open excel spreadsheet using VBScript. My problem is that I can't seem to be able to get an object reference to excel if it's open already. I was able to open an excel workbook and add a sheet, but I wasn't able to connect to a spreadsheet it if it was already open. Anybody knows how to do it in VBScript? E.g: manually open MS Excel and type something in Sheet1. Then when you'd run this VBScript that I need, it would connect to Sheet1 and would display the content of it in a message box. Thanks a lot! JP |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank You!
JP "Tom Ogilvy" wrote: have you tried using GetObject instead of CreateObject? Assuming you are NOT talking about Excel VBA when you say VBScript -- Regards, Tom Ogilvy "JP" wrote in message ... I need to manipulate an already open excel spreadsheet using VBScript. My problem is that I can't seem to be able to get an object reference to excel if it's open already. I was able to open an excel workbook and add a sheet, but I wasn't able to connect to a spreadsheet it if it was already open. Anybody knows how to do it in VBScript? E.g: manually open MS Excel and type something in Sheet1. Then when you'd run this VBScript that I need, it would connect to Sheet1 and would display the content of it in a message box. Thanks a lot! JP |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
JP,
Try using Set xlApp = GetObject(,"Excel.Application") rather than Set xlApp = CreateObject("Excel.Application") or better still, use both Set xlApp = Nothing On Error Resum Next Set xlApp = GetObject(","Excel.Application") On Error Goto 0 If xlApp Is Nothing 'no instance of Excel running, so create one Set xlApp = CreateObject("Excel.Application") If xlApp Is Nothing Then MsgBox "Fatal error" Exit Sub End If End If -- HTH Bob Phillips "JP" wrote in message ... I need to manipulate an already open excel spreadsheet using VBScript. My problem is that I can't seem to be able to get an object reference to excel if it's open already. I was able to open an excel workbook and add a sheet, but I wasn't able to connect to a spreadsheet it if it was already open. Anybody knows how to do it in VBScript? E.g: manually open MS Excel and type something in Sheet1. Then when you'd run this VBScript that I need, it would connect to Sheet1 and would display the content of it in a message box. Thanks a lot! JP |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thank You very much! Great help!
JP "Bob Phillips" wrote: JP, Try using Set xlApp = GetObject(,"Excel.Application") rather than Set xlApp = CreateObject("Excel.Application") or better still, use both Set xlApp = Nothing On Error Resum Next Set xlApp = GetObject(","Excel.Application") On Error Goto 0 If xlApp Is Nothing 'no instance of Excel running, so create one Set xlApp = CreateObject("Excel.Application") If xlApp Is Nothing Then MsgBox "Fatal error" Exit Sub End If End If -- HTH Bob Phillips "JP" wrote in message ... I need to manipulate an already open excel spreadsheet using VBScript. My problem is that I can't seem to be able to get an object reference to excel if it's open already. I was able to open an excel workbook and add a sheet, but I wasn't able to connect to a spreadsheet it if it was already open. Anybody knows how to do it in VBScript? E.g: manually open MS Excel and type something in Sheet1. Then when you'd run this VBScript that I need, it would connect to Sheet1 and would display the content of it in a message box. Thanks a lot! JP |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Word with embedded Excel object which has reference to addin | Excel Discussion (Misc queries) | |||
excel 2000 object reference anywhere? | Excel Programming | |||
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed | Excel Programming | |||
Excel Object Library Reference | Excel Programming | |||
Workbooks.Open(filename) : Returning err: Object reference not... (in VB.NET) | Excel Programming |