Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Toggle Settings

0 views
Skip to first unread message

AA

unread,
Jun 2, 2004, 10:41:16 PM6/2/04
to
I'd like to be able to toggle some settings, for example "Windows in
TaskBar" or "View Text Boundaries".

Currently I have two macros to do this sort of thing, one for off and
one for on, and either two toolbar buttons or two shortcut keys to
activate the pairs of macros.

Is there a way to test for a setting? For example, to show text
boundaries, I use

ActiveWindow.View.ShowTextBoundaries = True

How would I test for whether they are on or off, so I could do the
appropriate If/Then and set up a toggle?

TIA,

Andy

Jean-Guy Marcil

unread,
Jun 2, 2004, 11:25:11 PM6/2/04
to
Bonjour,

Dans son message, < AA > écrivait :

All you need is one macro (and one button) with something like

With ActiveWindow.View
.ShowTextBoundaries = Not .ShowTextBoundaries
End With

If you want to get fancy, you can even change the look of the button every
time it is clicked on with something like

'_______________________________________
Dim Cbar As CommandBar
Dim MyButton As CommandBarButton

With ActiveWindow.View
.ShowTextBoundaries = Not .ShowTextBoundaries
End With

Set Cbar = CommandBars("TestBar")
With Cbar
Set MyButton = .Controls(1)
With MyButton
If ActiveWindow.View.ShowTextBoundaries Then
.State = msoButtonDown
Else
.State = msoButtonUp
End If
End With
End With
'_______________________________________

You will need a toolbar called "TestBar" on which the first button is the
one calling the toggling macro.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarci...@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

AA

unread,
Jun 3, 2004, 1:13:28 AM6/3/04
to

> All you need is one macro (and one button) with something like
>
> With ActiveWindow.View
> .ShowTextBoundaries = Not .ShowTextBoundaries
> End With

Sweet!

Any reason not to just make it one line (it is on one line, even if it formats differently
in this post)? This seems to work ok:

ActiveWindow.View.ShowTextBoundaries = Not ActiveWindow.View.ShowTextBoundaries

Is there an advantage to With,End With?


> If you want to get fancy, you can even change the look of the button every

> time it is clicked on with something like......

Oh that's exactly the sort of thing I'd waste a few hours playing with, probably when I
have work I really have to do. I'd love to have changing buttons.

Another time.

Merci Jean-Guy!!!

Andy


Jean-Guy Marcil

unread,
Jun 3, 2004, 11:38:03 AM6/3/04
to
Bonjour,

Dans son message, < AA > écrivait :
In this message, < AA > wrote:

||| All you need is one macro (and one button) with something like
|||
||| With ActiveWindow.View
||| .ShowTextBoundaries = Not .ShowTextBoundaries
||| End With
||
|| Sweet!
||
|| Any reason not to just make it one line (it is on one line, even if it
formats differently
|| in this post)? This seems to work ok:
||
|| ActiveWindow.View.ShowTextBoundaries = Not
ActiveWindow.View.ShowTextBoundaries
||
|| Is there an advantage to With,End With?

I have not trained in programming, but I remember someone explaining that
every time you add a dot in the code, this creates a new reference in the
memory. So, to be on the safe side and to avoid cluttering up the memory
(And help the code run faster, I think) I try to use "With ... End With"
whenever it will save me a few dots, also, it makes the code easier to read
as it is not as cluttered with repeated object.

||
||
||| If you want to get fancy, you can even change the look of the button
every
||| time it is clicked on with something like......
||
|| Oh that's exactly the sort of thing I'd waste a few hours playing with,
probably when I
|| have work I really have to do. I'd love to have changing buttons.

You could easily adapt the code I posted in a few minutes...

||
|| Another time.
||
|| Merci Jean-Guy!!!

De rien!

AA

unread,
Jun 4, 2004, 12:06:27 AM6/4/04
to
> if you want to get fancy, you can even change the look of the
> button every time it is clicked on with something like ....

> You will need a toolbar called "TestBar" on which the first button
> is the one calling the toggling macro.

Ah, the separate toolbar is the rub. Right now I have the button
right in the middle of my regular toolbar, so I would have to move it
off to one side.

> I have not trained in programming, but I remember someone
> explaining that every time you add a dot in the code, this creates
> a new reference in the memory. So, to be on the safe side and to
> avoid cluttering up the memory (And help the code run faster, I
> think) I try to use "With ... End With" whenever it will save me a
> few dots, also, it makes the code easier to read as it is not as
> cluttered with repeated object.

Interesting.

Thanks,

Andy


0 new messages