Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2008

Tip: Looking for answers? Try searching our database.

Different Effects App/App with IDE visible???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Julian - 07 Feb 2008 13:03 GMT
I've been annoyed by this for years, but now to try and do something about
it...

Word 2002, currently under Vista HP (but it was the same behaviour under
XP...)

Sometimes code does one thing (the wrong thing/nothing) when it runs
automatically, and does exactly the right thing when single-stepped - or is
otherwise odd in its execution! - making debugging impossible!

Current problem: I have a self re-starting on-time loop to handle idle
actions... to let me know that it is running in the background I have
created two alternate buttons on a custom toolbar and toggle their .visible
state.

I can see the code setting the visible properties to the correct value, but
the buttons themselves often do not change visibility (they *do* seem to
change if I am watching in Word, but only at the point that I switch to the
VBA IDE... but this is not consistent behaviour: I *have* seen the icons
toggling away happily for hours...)

Buttons inited with e.g.
   Set extrasBar = CommandBars("Extras")
   Set idleLoopAButton = extrasBar.Controls("idleLoopA")

where idleLoopAButton  is a module global.

The idle loop looks like this

Static Sub idleLoopActions()
   Dim callCounter As Long

   callCounter = callCounter + 1
       On Error Resume Next
           If idleLoopAButton.Visible = False And idleLoopAButton.Visible =
True Then  ' dummy impossible test - only execute within if there is an
error accessing properties
               initIdleLoopRunIndicator
           End If
       On Error GoTo 0
   If callCounter Mod 2 = 0 Then
       idleLoopAButton.Visible = True          ' just toggle the visibility
of two buttons
       idleLoopBButton.Visible = False
   Else
       idleLoopAButton.Visible = False
       idleLoopBButton.Visible = True
   End If
   DoEvents
   ' do other stuff omitted from post...
end sub

I have "cleaned" the code (with "VBA Code Cleaner", deleted the toolbars and
reimported them from a backup file... and restarted Word (NOT restarting the
VBA IDE) but all to no effect - buttons not toggling!

Does anyone have any ideas?

TIA

PS Code has lots of userforms, and some other ActiveX (a spreadsheet as OWC
for example)

Signature

Julian I-Do-Stuff

Some Vista stuff, but mostly just Stuff at http://berossus,blogspot.com

Julian - 07 Feb 2008 13:23 GMT
Extra info...

It's something to do with events... if absolutely nothing happens then the
buttons don't change... but if I type Left-Arrow/Right-Arrow continuously it
happens every time...

Have tried turning ScreenUpdating on and off, using ScreenRefresh, resetting
parent toolbar visibility to TRUE, adding multiple DoEvents after each step
(1 gets an event posted, 2nd causes it to be handled... I think) - none of
which work...

I need to post some sort of null event - Word only seems to update the
screen on some sort of "appropriate" trigger

<sigh>

Ideas?

Signature

Julian I-Do-Stuff

Some Vista stuff, but mostly just Stuff at http://berossus,blogspot.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.