[comp.windows.ms] Strange Excel macro bug

tpoind@eatdust.uswest.COM (08/30/90)

I found this interesting bug in Excel macros 

Sofware versions: Excel 2.1C, Windows 3.0, Dyancomm/3270 3.0.

Background:
I'm writing a macro sheet to automate access to a mainframe with DDE to
Dynacomm/3270 (don't get me started on THEIR bugs).  My macros send a DDE
command to Dynacomm, then wait for the mainframe command to finish.  I keep
checking the Dynacomm status via a DDE request.  I first programmed the Excel
macros in a WHILE loop, waiting a few seconds, then getting the status via
DDE request.  This effectively locked out any other Excel use, which I didn't
really want to do.  I then rewrote the macro using ON.TIME, that would check
the status via the same DDE request, if it wasn't finished on the Dynacomm side
the macro will reschedule itself in a few seconds to check again.  The
Dyancomm script that processes the DDE commands keeps track of it's internal
status, and responds to a DDE request by replying a status variable.
I'm writing the macro sheet for others, and keeping the gory details hidden
is desirable.  The macro sheet has an auto_open named macro that hides the
macro sheet window, amoung other things.

Now the bug: 
The macro works just fine when the macro sheet is exposed, but fails 
when it it hidden!  The problem is that Excel seems to lose the "instruction
pointer" (the next cell to execute) when the macro sheet is hidden, jumping
to cell A2, when all my macros are in column B.  The REQUEST macro that gets 
the status from Dynacomm is in a subroutine, and the request is immediately 
followed by a RETURN.  As a work around, I put a RETURN in A2 (gag me)
and everthing seems to work.  There are NO references to A2 in any of 
my defined names, which I use extensively.

I really haven't figured out yet if the bug is caused by DDE, the ON.TIME (my
suspect), or some odd combination of circumstance, the moon is full, etc.

Any MS'ers on the net, feel free to forward this to your Excel group.

Thanks in advance for any help/suggestions/sympathy!
Tom

-Tom Poindexter		tpoind@uswest.com