VBA responding erratically

S

Seeb

Hi everybody,

I'm using a lot of VBA code to handle events happening to Visio shapes
in a document, based on their Master.BaseID so I know which type of shape
I'm dealing with... I also interact with an Access database to insert values
in tables depending on the shapes added and also connections added between
those shapes.. But it seems that the events are not always triggered when
they happen..

Is it possible that VBA stops responding after an error message showed up or
something like this?

Thanks!
 
A

Al Edlund

there are a phenomenal number of things happening in the background as you
execute these types of applications. It is possible for the code you execute
to get ahead of what the system and ole objects have completed and the get
locked up. I usually put a lot of doevents into any routine that has to
leave main line code to do anything (like update a cell, database, etc.)
al
 
A

Al Edlund

I put a "DoEvents" instruction anywhere in the application that has
significant loop counts (which means I may have multiple in a single
routine), or has to interface with another routine.
Al
 
S

Seeb

Hi Al,

I tried the DoEvents function and it seems to work fine now... if I
understand when DoEvents is called, the application executes every event in
its queue before reading the next line of code under the DoEvents
instruction?

But while doing this, what happens if there's an event in that queue
that has some VBA code attached to it? Will it be executed anyway?

Thanks!

Seeb
 
A

Al Edlund

It's my understanding that doevents allows the system to take over and
execute processing of things that may be queued up (including events that
you may have queued).
al
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top