Macro for commandbar 
Author Message
 Macro for commandbar

Hi, I tried to get the name(string) of my button in a
custom menu I have created. The commmand must refer to the
active button in my active "menu".

Question: How to set this macro (this is my test)

With CommandBars.ActiveMenuBar.Controls
    .Caption = myname
Selection.InsertFile
FileName:="c:\document\piece.doc", Range:=myname, _
ConfirmConversions:=False, Link:=True, Attachment:=False

End With



Fri, 04 Mar 2005 22:36:58 GMT  
 Macro for commandbar
Hi Francois,

If you try to find the caption of the control that was pressed, try:

--------------------------------------------------
Dim oControl As CommandBarControl

  Set oControl = CommandBars.ActionControl
  If Not oControl Is Nothing Then
    MsgBox oControl.Caption
  End If

  Set oControl = Nothing
--------------------------------------------------

Hope this helps,
regards,
Astrid

So that all can benefit from the discussion, please post all follow-ups to the newsgroup.
Visit the MVP Word FAQ site at http://www.mvps.org/word/


Quote:
> Hi, I tried to get the name(string) of my button in a
> custom menu I have created. The commmand must refer to the
> active button in my active "menu".

> Question: How to set this macro (this is my test)

> With CommandBars.ActiveMenuBar.Controls
>     .Caption = myname
> Selection.InsertFile
> FileName:="c:\document\piece.doc", Range:=myname, _
> ConfirmConversions:=False, Link:=True, Attachment:=False

> End With



Sat, 05 Mar 2005 05:49:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. WD2000: Autoexec macro CommandBar Bug?

2. VBA - Macros - CommandBars - Expert Required!

3. VBA - Macros - CommandBars - Expert Required!

4. Commandbars for Export, binding controls to macros

5. How can I create a CommandBar with a button that execute a macro and a ComboBox?

6. macro box pops up when no macros exist

7. macro changing code in another macro

8. macro to change code in another macro

9. How to make changes in macros with help of anather macro

10. Word Macro runs then gets Macro Not Found

11. Removing the [ENABLE MACROS] [DISABLE MACROS] popup window

12. Word 97 Macros > Word XP Macros

 

 
Powered by phpBB® Forum Software