Group:  Microsoft Word ยป microsoft.public.word.vba.customization
Thread: New toolbar? Word 2003

New toolbar? Word 2003
"androo..." <rodv[ at ]globalnet.co.uk> 12/28/2008 5:31:24 PM
How do I find out in VBA if a toolbar called "avCombined" exists in Word
2003?

Thanks in advance
androoooooooooooooooo.................

Re: New toolbar? Word 2003
Jay Freedman <jay.freedman[ at ]verizon.net> 12/28/2008 8:01:48 PM
On Sun, 28 Dec 2008 17:31:24 -0000, "androo..." <rodv[ at ]globalnet.co.uk> wrote:

[Quoted Text]
>How do I find out in VBA if a toolbar called "avCombined" exists in Word
>2003?
>
>Thanks in advance
>androoooooooooooooooo.................

Sub x()
Dim oCB As CommandBar

For Each oCB In ActiveDocument.CommandBars
If LCase(oCB.NameLocal) = "avcombined" Then
'do something with oCB, such as
MsgBox "avCombined exists"

Exit For ' don't need to look any further after finding one
End If
Next
End Sub


--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit.
Re: New toolbar? Word 2003
"Gordon Bentley-Mix via OfficeKB.com" <u44607[ at ]uwe> 12/29/2008 4:18:26 AM
Or you could try something like this:

Public Function fcnFindToolbar(myToolbarName As String) As Boolean
Dim myValue As String
fcnFindToolbar = False
On Error Resume Next
myValue = CommandBars(myToolbarName).Name
If Err.Number = 0 Then fcnFindToolbar = True
End Function

(Credit to Greg Maxey for showing me how to do this with document variables.)

This is called as shown in the following example:

Sub Test()
If fcnFindToolbar("avCombined") = True Then
'Do stuff based on finding the toolbar
Else
'Do stuff based on NOT finding the toolbar
End If
End Sub

This has the advantage of not requiring the code to loop through all of the
CommandBars in the CommandBars collection (there are over 140 in a standard
install of Office), so it will execute quicker.


androo... wrote:
[Quoted Text]
>How do I find out in VBA if a toolbar called "avCombined" exists in Word
>2003?
>
>Thanks in advance
>androoooooooooooooooo.................

--
--
Cheers!
Gordon

Uninvited email contact will be marked as SPAM and ignored. Please post all
follow-ups to the newsgroup.

Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.aspx/word-programming/200812/1

Re: New toolbar? Word 2003
"androo..." <rodv[ at ]globalnet.co.uk> 12/29/2008 9:33:36 PM
Thanks.

Regards,
androoooooooooooooooo...........................

Home | Search | Terms | Imprint
Newsgroups Reader