Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
JP JP is offline
external usenet poster
 
Posts: 103
Default How to get an object reference to an ALREADY open excel spreadshee

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to get an object reference to an ALREADY open excel spreadshee

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   Report Post  
Posted to microsoft.public.excel.programming
JP JP is offline
external usenet poster
 
Posts: 103
Default How to get an object reference to an ALREADY open excel spread

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default How to get an object reference to an ALREADY open excel spreadshee

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   Report Post  
Posted to microsoft.public.excel.programming
JP JP is offline
external usenet poster
 
Posts: 103
Default How to get an object reference to an ALREADY open excel spread

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word with embedded Excel object which has reference to addin Tom Chau Excel Discussion (Misc queries) 0 September 6th 06 02:25 AM
excel 2000 object reference anywhere? Lore Leuneog Excel Programming 1 October 25th 04 09:57 AM
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 Frank Jones Excel Programming 2 June 15th 04 03:21 AM
Excel Object Library Reference francis cheuk Excel Programming 1 February 11th 04 06:15 PM
Workbooks.Open(filename) : Returning err: Object reference not... (in VB.NET) bryan Excel Programming 2 January 20th 04 07:42 PM


All times are GMT +1. The time now is 12:38 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"