B
Bob Chisholm
I'm attempting to add an item to the Tools menu in Word97 running in
Windows ME. The purpose is to provide the user a means to invoke a
special process (via VBA) on demand. The code I've tried is:
Private Sub Document_Open()
Dim lPos As Long
Dim objToolsMenu As CommandBar
Dim objToolsItem As CommandBarControl
Set objToolsMenu = Application.CommandBars("Tools")
lPos = objToolsMenu.Controls.Count
Set objToolsItem = objToolsMenu.Controls.Add(msoControlPopup, 1, ,
lPos + 1, True)
objToolsItem.Caption = "&Get Label Data"
objToolsItem.BeginGroup = True
objToolsItem.OnAction = "_Document2!GetLabelData"
End Sub
This code places the desired item on the Tools menu at the desired
location. My problem is that the "True" value for the "Temporary"
parameter in the objToolsMenu.Controls.Add ignored. After the Word
aapplication is closed, and then reinvoked with any document, the added
item in the Tools menu remains. If several documents are opened in
separate invocations of Word (with the choice of enabling macros), the
added item appears an additional time in the Tools menu for each.
How can I clear the Tools menu of these unwanted Permanent added items?
How can I get added items to be truly Temporary? Is the use of
msoControlPopup as the value of the "Type" parameter improper? I
confess having adapted the above code from successful Excel programming
wherein the "Type" parameter was msoControlButton, but this value was
unrecognized by Word.
Your expertise earnestly sought.
Bob
Windows ME. The purpose is to provide the user a means to invoke a
special process (via VBA) on demand. The code I've tried is:
Private Sub Document_Open()
Dim lPos As Long
Dim objToolsMenu As CommandBar
Dim objToolsItem As CommandBarControl
Set objToolsMenu = Application.CommandBars("Tools")
lPos = objToolsMenu.Controls.Count
Set objToolsItem = objToolsMenu.Controls.Add(msoControlPopup, 1, ,
lPos + 1, True)
objToolsItem.Caption = "&Get Label Data"
objToolsItem.BeginGroup = True
objToolsItem.OnAction = "_Document2!GetLabelData"
End Sub
This code places the desired item on the Tools menu at the desired
location. My problem is that the "True" value for the "Temporary"
parameter in the objToolsMenu.Controls.Add ignored. After the Word
aapplication is closed, and then reinvoked with any document, the added
item in the Tools menu remains. If several documents are opened in
separate invocations of Word (with the choice of enabling macros), the
added item appears an additional time in the Tools menu for each.
How can I clear the Tools menu of these unwanted Permanent added items?
How can I get added items to be truly Temporary? Is the use of
msoControlPopup as the value of the "Type" parameter improper? I
confess having adapted the above code from successful Excel programming
wherein the "Type" parameter was msoControlButton, but this value was
unrecognized by Word.
Your expertise earnestly sought.
Bob