Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
Word
application.errors
conversions
docmanagement
drawing.graphics
formatting.longdocs
international
internet.assistant
mail
mailmerge.fields
menustoolbars
newusers
numbering
oleinterop
pagelayout
printingfonts
setup.networking
spelling.grammar
tables
vba.addins
vba.beginners
vba.customization
vba.general
vba.userforms
web.authoring
word6-7macros
word97vba
  
 
date: Mon, 30 Jan 2006 10:59:30 -0800,    group: microsoft.public.word.vba.customization        back       


Toggle Toolbar Button for Toggle Macro   
In Word I have several toggle macros that I run from toolbar buttons.  I 
would like them to behave like the Word Bold, Underline, etc., toolbar 
buttons - change depending on whether the button is depressed or not.  Can 
anyone help me with VBA code to do that?  Thanks in advance.

Sjane
date: Mon, 30 Jan 2006 10:59:30 -0800   author:   sjane

Re: Toggle Toolbar Button for Toggle Macro   
"sjane" wrote:
> In Word I have several toggle macros that I run from toolbar buttons.
> I would like them to behave like the Word Bold, Underline, etc., toolbar
> buttons - change depending on whether the button is depressed or not.
> Can anyone help me with VBA code to do that?  Thanks in advance.
>
> Sjane


Hi Sjane,

Look at the help for the State property of the CommandBarButton object.

Regards,
Klaus
date: Wed, 8 Feb 2006 22:56:49 +0100   author:   Klaus Linke

Re: Toggle Toolbar Button for Toggle Macro   
"Klaus Linke" wrote:

> "sjane" wrote:
> > In Word I have several toggle macros that I run from toolbar buttons.
> > I would like them to behave like the Word Bold, Underline, etc., toolbar
> > buttons - change depending on whether the button is depressed or not.
> > Can anyone help me with VBA code to do that?  Thanks in advance.
> >
> > Sjane
> 
> 
> Hi Sjane,
> 
> Look at the help for the State property of the CommandBarButton object.
> 
> Regards,
> Klaus 
> 
> Klaus - thank you for your response.  I spent some time reading up on the "state" property and tried to test out the example code given in the VBA help but didn't get very far - got  an error in code below at second line "Expected:=" - do you have any other suggestions I can look into?  Thanks in advance.

Set myBar = CommandBars _
    .Add(Name:="Custom", Position:=msoBarTop, _
    Temporary:=True)
With myBar
    .Controls.Add Type:=msoControlButton, ID:=1
    .Controls.Add Type:=msoControlButton, ID:=2
    .Visible = True
End With
Set myControl1 = CommandBars("Custom").Controls(1)
myControl1.State = msoButtonUp
Set myControl2 = CommandBars("Custom").Controls(2)
myControl2.State = msoButtonDown

>
date: Thu, 9 Feb 2006 11:49:27 -0800   author:   sjane

Re: Toggle Toolbar Button for Toggle Macro   
Hi Sjane,

You get the error message because the contol with Id:=2 is "ToolsSpelling".
The built-in commands are handled by the application. You can't set their 
state.

Custom controls all have the Id:=1.

Two comments regarding the code:

-- Instead of
  myBar.Controls.Add Type:=msoControlButton, ID:=1
  Set myControl1 = CommandBars("Custom").Controls(1)
it might be better (less error-prone) to use
  Set myControl1 = _
     myBar.Controls.Add(Type:=msoControlButton, ID:=1)
That way, you're sure myControl1 refers to what you think.

-- The .Temporary property of the CommandBar object is something from Excel 
and has no meaning in Word, IIRC.

Regards,
Klaus






"sjane" schrieb:
>
>
> "Klaus Linke" wrote:
>
>> "sjane" wrote:
>> > In Word I have several toggle macros that I run from toolbar buttons.
>> > I would like them to behave like the Word Bold, Underline, etc., 
>> > toolbar
>> > buttons - change depending on whether the button is depressed or not.
>> > Can anyone help me with VBA code to do that?  Thanks in advance.
>> >
>> > Sjane
>>
>>
>> Hi Sjane,
>>
>> Look at the help for the State property of the CommandBarButton object.
>>
>> Regards,
>> Klaus
>>
>> Klaus - thank you for your response.  I spent some time reading up on the 
>> "state" property and tried to test out the example code given in the VBA 
>> help but didn't get very far - got  an error in code below at second line 
>> "Expected:=" - do you have any other suggestions I can look into?  Thanks 
>> in advance.
>
> Set myBar = CommandBars _
>    .Add(Name:="Custom", Position:=msoBarTop, _
>    Temporary:=True)
> With myBar
>    .Controls.Add Type:=msoControlButton, ID:=1
>    .Controls.Add Type:=msoControlButton, ID:=2
>    .Visible = True
> End With
> Set myControl1 = CommandBars("Custom").Controls(1)
> myControl1.State = msoButtonUp
> Set myControl2 = CommandBars("Custom").Controls(2)
> myControl2.State = msoButtonDown
>
>>
date: Mon, 13 Feb 2006 17:39:14 +0100   author:   Klaus Linke

Re: Toggle Toolbar Button for Toggle Macro   
.... and another comment: If you use
Dim myButton1 as CommandBarButton
instead of
Dim myControl1 as CommandBarControl
you'll get more help from IntelliSense (say, the .State property <g>)

Klaus
date: Mon, 13 Feb 2006 17:43:44 +0100   author:   Klaus Linke

Re: Toggle Toolbar Button for Toggle Macro   
Hi Klaus 
Thanks for your help - I am very glad to have this forum and the assistance 
of all you experts - especially since Word VBA "help" doesn't always!  Have a 
great day.

Sjane

"Klaus Linke" wrote:

> .... and another comment: If you use
> Dim myButton1 as CommandBarButton
> instead of
> Dim myControl1 as CommandBarControl
> you'll get more help from IntelliSense (say, the .State property <g>)
> 
> Klaus 
> 
> 
>
date: Mon, 13 Feb 2006 09:01:29 -0800   author:   sjane

Re: Toggle Toolbar Button for Toggle Macro   
"sjane" wrote:
> Hi Klaus
> Thanks for your help - I am very glad to have this forum and the 
> assistance
> of all you experts - especially since Word VBA "help" doesn't always!
> Have a great day.
>
> Sjane

Glad it helped -- And do come back. Before you'll know what happened, you'll 
be addicted to the newsgroups.
Oops, we're not supposed to disclose that!

Klaus
date: Wed, 15 Feb 2006 14:11:35 +0100   author:   Klaus Linke

Re: Toggle Toolbar Button for Toggle Macro   
> Glad it helped -- And do come back. Before you'll know what happened,
you'll
> be addicted to the newsgroups.
> Oops, we're not supposed to disclose that!

LOL! Very true!

--
Enjoy,
Tony


"Klaus Linke"  wrote in message
news:O93ohEjMGHA.1536@TK2MSFTNGP11.phx.gbl...
> "sjane" wrote:
> > Hi Klaus
> > Thanks for your help - I am very glad to have this forum and the
> > assistance
> > of all you experts - especially since Word VBA "help" doesn't always!
> > Have a great day.
> >
> > Sjane
>
> Glad it helped -- And do come back. Before you'll know what happened,
you'll
> be addicted to the newsgroups.
> Oops, we're not supposed to disclose that!
>
> Klaus
>
>
date: Wed, 15 Feb 2006 15:20:33 -0000   author:   Tony Jollans My Forename at My Surname dot com

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us