Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run Macro in another workbook already OPENED in another instance of Excel

Hello,

I know how to open another workbook in another instance of Excel and
run a macro:

e.g.
Set xlApp = CreateObject("Excel.Application")
Set wbChart = xlApp.Workbooks.Open(filename:=ThisWorkbook.Path &
"\chart.xls")
xlApp.Run "chart.xls!mcrUpdateES", dteClose_15, dblHI_15, dblLO_15,
dblLast

But how do I do this if the workbook is ALREADY OPENED in another
instance of Excel? I think the problem centers on how to identify the
seperate instance of Excel that is already running. i.e. it's easy to
know that "xlApp" refers to the seperate instance if I'm creating that
instance at run-time, but how to refer to the seperate instance if it
was created before run-time.

Any help greatly appreciated.
Ben.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,939
Default Run Macro in another workbook already OPENED in another instance o

You should focus your attention on keeping everything in one instance of
Excel. Multiple instances will cause you nothing but grief because each
instance stands alone and knows nothing of the other instance... A workbook
in one instance has no (easy) way to communicate with workbooks in another
instance...
--
HTH...

Jim Thomlinson


" wrote:

Hello,

I know how to open another workbook in another instance of Excel and
run a macro:

e.g.
Set xlApp = CreateObject("Excel.Application")
Set wbChart = xlApp.Workbooks.Open(filename:=ThisWorkbook.Path &
"\chart.xls")
xlApp.Run "chart.xls!mcrUpdateES", dteClose_15, dblHI_15, dblLO_15,
dblLast

But how do I do this if the workbook is ALREADY OPENED in another
instance of Excel? I think the problem centers on how to identify the
seperate instance of Excel that is already running. i.e. it's easy to
know that "xlApp" refers to the seperate instance if I'm creating that
instance at run-time, but how to refer to the seperate instance if it
was created before run-time.

Any help greatly appreciated.
Ben.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 272
Default Run Macro in another workbook already OPENED in another instance o

I tend to agree with Jim on this one, but I'll answer your question anyhow.
Use the GetObject function instead of CreateObject, like this:
Set xlApp = GetObject(,"Excel.Application")
--
Charles Chickering

"A good example is twice the value of good advice."


" wrote:

Hello,

I know how to open another workbook in another instance of Excel and
run a macro:

e.g.
Set xlApp = CreateObject("Excel.Application")
Set wbChart = xlApp.Workbooks.Open(filename:=ThisWorkbook.Path &
"\chart.xls")
xlApp.Run "chart.xls!mcrUpdateES", dteClose_15, dblHI_15, dblLO_15,
dblLast

But how do I do this if the workbook is ALREADY OPENED in another
instance of Excel? I think the problem centers on how to identify the
seperate instance of Excel that is already running. i.e. it's easy to
know that "xlApp" refers to the seperate instance if I'm creating that
instance at run-time, but how to refer to the seperate instance if it
was created before run-time.

Any help greatly appreciated.
Ben.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default Run Macro in another workbook already OPENED in another instance of Excel

Ben,
Unless you have a good reason that requires more than one instance of Excel
use the single instance, as the other replies have suggested.
However if required, you can use GetObject to return a reference to an Excel
instance, but you cannot be sure which instance you get; it is determined by
the OS and should be considered random.

Peter T has written about this a few times
http://groups.google.co.uk/group/mic...50af98 b97529

However, as it seems you have the Path/Filename, this should do:
http://groups.google.co.uk/group/mic...78af9f b56ca8

NickHK

wrote in message
ups.com...
Hello,

I know how to open another workbook in another instance of Excel and
run a macro:

e.g.
Set xlApp = CreateObject("Excel.Application")
Set wbChart = xlApp.Workbooks.Open(filename:=ThisWorkbook.Path &
"\chart.xls")
xlApp.Run "chart.xls!mcrUpdateES", dteClose_15, dblHI_15, dblLO_15,
dblLast

But how do I do this if the workbook is ALREADY OPENED in another
instance of Excel? I think the problem centers on how to identify the
seperate instance of Excel that is already running. i.e. it's easy to
know that "xlApp" refers to the seperate instance if I'm creating that
instance at run-time, but how to refer to the seperate instance if it
was created before run-time.

Any help greatly appreciated.
Ben.



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
How to run macro from Add-In when Excel opened workbook? Sergiy Excel Programming 10 August 14th 06 05:22 PM
Macro in Excel to check if another workbook is opened. Catalin[_3_] Excel Programming 3 August 5th 06 07:31 AM
Macro won't run in Excel 2000 when workbook opened via URL [email protected] Excel Programming 0 March 29th 06 10:52 PM
Load a range of cells into a dataset with an opened workbook instance. [email protected] Excel Programming 0 May 31st 05 04:32 PM
Set up Excel to start new instance for each new file opened. Minimal_Subset Excel Discussion (Misc queries) 2 May 12th 05 01:36 AM


All times are GMT +1. The time now is 12:18 AM.

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

About Us

"It's about Microsoft Excel"