If a Button is active, make it inactive, and back the way it was

C

CJ

Word 2003 XP environment
Would anyone be willing to help me with determining if what state the
Show/Hide button is in, if Show All is true, make it false, do stuff, then
when done, make it true again.

I make turn it off and on for all users with no problem. Problem is, not
everyone has Show All active, and I need to turn it off for only those users
and then turn it back on. If it's false, then just do the stuff that needs
to be done.

Thanks, I hope, for help.
 
J

Jay Freedman

CJ said:
Word 2003 XP environment
Would anyone be willing to help me with determining if what state the
Show/Hide button is in, if Show All is true, make it false, do stuff,
then when done, make it true again.

I make turn it off and on for all users with no problem. Problem is,
not everyone has Show All active, and I need to turn it off for only
those users and then turn it back on. If it's false, then just do
the stuff that needs to be done.

Thanks, I hope, for help.

The general principle is to save the current setting in a variable; set it
the way you need it (even if it's already set that way, it doesn't hurt to
set it again); do the work; and then set it back to the stored value (again,
it doesn't hurt to set it again to its current value).

Sub x()
Dim userShowAll As Boolean
userShowAll = ActiveWindow.View.ShowAll
ActiveWindow.View.ShowAll = False

' do stuff

ActiveWindow.View.ShowAll = userShowAll
End Sub

Also note that the state of the button may or may not change while the macro
is running, but the display of the document will change, which is the
important bit.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
C

CJ

Thank you so much, Jay. I figured it would have to be a variable, but
couldn't figure out how to set it out.
 

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