LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default How do I access a variable from another instance of excel?

Hi Alan,

That is a great idea - I will definately run with this one to see
where it takes me.


Glad you like it.

Re my "Big point", I meant to add that updating progress 000's of times
might take longer than the actual routine on its own - though I see not an
issue for you.

One question:

If I use GetObject to create a reference in NewExcel to OldExcel (and
then I can presumably directly control any object in OldExcel from
within NewExcel including OldExcel.StatusBar) I will have a reference
in both directions (OldExcel will contain NewExcel and NewExcel will
contain an Object that is OldExcel).


Exactly, cross referrenced instances of Excel, each can manipulate the
other.

In general is that an issue?


Possibly, let's take the least problematic ref first - "xlOld" in NewExcel.

I don't know if you want this as Public for later use, or as a one off at
procedure level while doing your stuff. In either case eventually it should
be set to Nothing. In the example I declared it Public, not knowing how you
want to use it as a precaution I set it to nothing in the Auto_close. But do
that where ever is most appropriate.

"xlNew" in ExcelOld is the one to be concerned with if has been used to
create the new instance. Eventually it should be set to nothing but NOT
until after NewExcel is closed, either programatically or manually. In the
worst case, if NewExcel is not visible, you won't be able to close it
without using the task manager, or Ctrl Alt Del and looking for "Excel" and
End task.

If you are opening your wb in a new instance to do a specific task (visible
?) after which you no longer need the new instance, do this:

wb.close false ' or true ?
set wb = nothing
xlNew.quit
set xlNew = nothing

If wb and/or NewExcel could have been closed by other means, run the above
under "On Error resume next".

Re-reading my Test proc I see that I set xlNew to nothing with NewExcel
still open. Not a major problem as I also made NewExcel visible. However
running this several times might lead to a memory leak. Having said that I
didn't notice any problems testing a few times.

Conceptually (I am weak on this), I tend to think of object 'trees'
with each object being a branch off of its parent. However, in this
case we have a circular loop of 'containers'. Is that likely to store
up potential issues?


I don't see these cross ref's as a "circular loop of 'containers'", so
providing the above precautions are followed I don't think there should be
any problems. But if anyone wants to step in and say otherwise ... I'll be
interested myself.

Regards,
Peter T



 
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
Access to Variable C Brandt Excel Discussion (Misc queries) 1 June 5th 07 05:19 PM
Import into Access from Excel, passing a variable for the field... [email protected] Excel Worksheet Functions 1 April 12th 07 09:44 AM
Transpose a variable length list into Excel / Access Table Pete New Users to Excel 11 September 13th 06 07:37 PM
Trying to access different files depening on a variable Priorsyeat Excel Discussion (Misc queries) 1 April 6th 06 01:13 PM
I Need VBA Assistance regarding passing a variable from Access Brent E Excel Programming 1 March 1st 05 08:16 PM


All times are GMT +1. The time now is 08:10 AM.

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"