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 / January 2006

Tip: Looking for answers? Try searching our database.

msoControlButton does not show until after customize

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Grumpy - 07 Jan 2006 17:59 GMT
Word 2003

When I add a control button to the "Tools" menu the button does not appear
until I click on 'View -> Toolbars -> customize -> then open the 'Tools'
menu and then close the customize session.

What am I doing wrong please?

Sub AddMenu()

   Dim myMenubar As CommandBar
   Dim ACCRControl, ctl, myControl As CommandBarControl

   Set myMenubar = CommandBars.ActiveMenuBar
   Set myControl = myMenubar.Controls(6)

   For Each ctl In myControl.Controls
       If ctl.Caption = "Load ACCRs" Then
           Exit Sub
       End If
   Next

   Set ACCRControl = myControl.Controls.Add _
    (Type:=msoControlButton, _
     ID:=1, temporary:=False)

   With ACCRControl
      .Caption = "Load ACCRs"
      .DescriptionText = "Loads ACCRs from list in table"
      .OnAction = "LoadACCRs"
      .Enabled = True
      .Visible = True
   End With

End Sub
Tony Jollans - 08 Jan 2006 11:57 GMT
The code works fine for me (Word 2003) and I can't see any obvious reason
why it shouldn't work. Although I wouldn't expect it, could it be that the
control is there and only shown in the full menu so that you don't see it
immediately when clicking on Tools?

I would just point out that ...

>     Dim ACCRControl, ctl, myControl As CommandBarControl

declares myControl as a CommandBarControl
and ACCRControl and ctl as Variants.

--
Enjoy,
Tony

> Word 2003
>
[quoted text clipped - 31 lines]
>
> End Sub
Grumpy - 09 Jan 2006 20:03 GMT
Thanks for the response and your point out.

I changed the declaration and everthing is OK.  The control appears first
time everytime.  I don't suppose I have to understand why.
Thanks again.

> The code works fine for me (Word 2003) and I can't see any obvious reason
> why it shouldn't work. Although I wouldn't expect it, could it be that the
[quoted text clipped - 48 lines]
>>
>> End Sub
Tony Jollans - 10 Jan 2006 10:49 GMT
'fraid I can't explain that either! But glad it's working.

--
k}
> Thanks for the response and your point out.
>
[quoted text clipped - 54 lines]
> >>
> >> End Sub
 
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.