LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default COM and threading in VBA


-- Crossposted on :

microsoft.public.office.developer.vba
microsoft.public.office.developer.clipboard.dde
microsoft.public.vb.ole
microsoft.public.win32.programmer.ole
microsoft.public.excel.programming

since I wasn't sure where the correct place for this was.



Hi all,

I've got a question about COM calls and threading in VBA. At least I think
that that's what the issue I am experiencing is.
Here is the problem that I'm seeing. I've got an Excel VBA application. It
has a primary COM object that the VBA code
instantiates and then calls the public methods and properties of this
object. This all works fine and dandy. Now, what I have
discovered is that we run into a problem if we have two copies of Excel
running at the same time and they are both making calls
to the COM object. It seems like the instance of Excel that I started first
will run and only when its complete, will the other
instance of Excel start running and doing things. It almost seems like its
waiting on the COM calls even though each Excel has its
own copy of the COM object so there is no lock involved there. I have also
noticed strange behavior with the Excel and the clipboard when one copy of
Excel is very
busy doing things with the COM object. In one instance of Excel, it seems
access to clipboard (do a range.Copy for instance) is
locked until a call to the COM object completes in the other running of
Excel. Now, I have found that if I put DoEvents() calls around
the COM object calls, this does change the pattern of behavior with the two
Excels. After the first running copy of Excel has made a COM
call, and a DoEvent call is done, the second copy of Excel will run, until
the first one gets to a point of making another COM call.
Then, once the call is done and the DoEvents call is made, the first copy
will startup again. It seems like DoEvents is releasing
a lock of some kind. The DoEvents call also seems to unlock the clipboard
as well, because the range.Copy call will go thru in one instance
of Excel right after I do the DoEvents call in the other instance of Excel.

Well, I'm not sure this makes much sense, because it doesn't really to me,
but if anyone has any ideas on it, please let me know.

Thanks in advance,
Nick


 
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
Excel Multi-threading Randy L[_2_] Excel Discussion (Misc queries) 2 February 16th 07 07:13 PM
Threading Problem ThisShouldBeEasy Excel Programming 0 June 9th 05 01:16 AM
Excel and Hyper-Threading Processors David Benson Excel Discussion (Misc queries) 3 March 24th 05 06:11 AM
ExcelTip/ExcelForum threading keepITcool Excel Programming 9 October 29th 04 04:40 PM
vba multi threading Steve[_42_] Excel Programming 1 October 29th 03 11:11 AM


All times are GMT +1. The time now is 08:53 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"