ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   how to Add a command button to the standard commandbar of the visual editor window (https://www.excelbanter.com/excel-programming/398539-how-add-command-button-standard-commandbar-visual-editor-window.html)

michdenis

how to Add a command button to the standard commandbar of the visual editor window
 
Hi,

This code add a button to the "standard" command bar of the
visual editor window ?

Does someone know why it does not work ?
and what to change to make it work.

'---------------------
Sub Test()

With ThisWorkbook.VBProject.VBE.CommandBars("Standard")
With .Controls.Add(msoControlButton)
.Style = msoButtonWrapCaption
.Caption = "Recherche"
.OnAction = "Module5.test1"
End With
End With

End Sub

'---------------------
Sub test1()
MsgBox "Good afternoon"
End Sub
'---------------------

Thank in advance for you time.

Salutations



JLGWhiz

how to Add a command button to the standard commandbar of the visu
 
Not absolutely sure, but pretty sure you didn't need the second With statment.

Sub Test()
With ThisWorkbook.VBProject.VBE.CommandBars("Standard") .Controls.Add
_(msoControlButton)
.Style = msoButtonWrapCaption
.Caption = "Recherche"
.OnAction = "Module5.test1"
End With
End Sub

I haven't tried adding anything in the VBE before, but it shouldn't be a lot
different that adding to an Excel menu bar.
"MichDenis" wrote:

Hi,

This code add a button to the "standard" command bar of the
visual editor window ?

Does someone know why it does not work ?
and what to change to make it work.

'---------------------
Sub Test()

With ThisWorkbook.VBProject.VBE.CommandBars("Standard")
With .Controls.Add(msoControlButton)
.Style = msoButtonWrapCaption
.Caption = "Recherche"
.OnAction = "Module5.test1"
End With
End With

End Sub

'---------------------
Sub test1()
MsgBox "Good afternoon"
End Sub
'---------------------

Thank in advance for you time.

Salutations




JLGWhiz

how to Add a command button to the standard commandbar of the visu
 
After checking some of the help files, it looks like you will need to use the
Set statement to get this to work.

"MichDenis" wrote:

Hi,

This code add a button to the "standard" command bar of the
visual editor window ?

Does someone know why it does not work ?
and what to change to make it work.

'---------------------
Sub Test()

With ThisWorkbook.VBProject.VBE.CommandBars("Standard")
With .Controls.Add(msoControlButton)
.Style = msoButtonWrapCaption
.Caption = "Recherche"
.OnAction = "Module5.test1"
End With
End With

End Sub

'---------------------
Sub test1()
MsgBox "Good afternoon"
End Sub
'---------------------

Thank in advance for you time.

Salutations




michdenis

how to Add a command button to the standard commandbar of the visu
 
Thanks for your participation.

If you're still interested, 2 addresses :

(near the bottom of the page ...)
http://usenet.p2preactor.com/index-t-1455761.html




http://www.cpearson.com/excel/VbeMenus.aspx





Salutations





"JLGWhiz" a écrit dans le message de news:
...
After checking some of the help files, it looks like you will need to use the
Set statement to get this to work.

"MichDenis" wrote:

Hi,

This code add a button to the "standard" command bar of the
visual editor window ?

Does someone know why it does not work ?
and what to change to make it work.

'---------------------
Sub Test()

With ThisWorkbook.VBProject.VBE.CommandBars("Standard")
With .Controls.Add(msoControlButton)
.Style = msoButtonWrapCaption
.Caption = "Recherche"
.OnAction = "Module5.test1"
End With
End With

End Sub

'---------------------
Sub test1()
MsgBox "Good afternoon"
End Sub
'---------------------

Thank in advance for you time.

Salutations







All times are GMT +1. The time now is 01:24 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com