Control Bars and Command Buttons??

M

MichaelA

Hello All,

I have been using Rod Gill's book to implement a toolbar with a button
that executes a particular module. The toolbar installs, no problem.
However, it doesn't matter how I write the VBA, the command button
just does not execute or even give an error.

The following is the code in "ThisProject" under the global.mpt

I would be grateful for any pointers on what is wrong here.


thanks
Michael Andersen


Dim MyBar As CommandBar
Dim MyButton As CommandBarButton

On Error Resume Next

Set MyBar = CommandBars("Macros")
If MyBar Is Nothing Then
Set MyBar = CommandBars.Add(Name:="Macros",
Position:=msoBarFloating, temporary:=True)
End If

Set MyButton = Nothing
Set MyButton = MyBar.Controls("Excel Export")
If MyButton Is Nothing Then
Set MyButton = MyBar.Controls.Add(Type:=msoControlButton)
With MyButton
.Style = msoButtonCaption
.Caption = "Excel Export"
.OnAction = "MacroNameHere"
End With
End If

MyBar.Visible = True
 
M

MichaelA

An update to this is that I have found that if I have the module to be
executed as not private, the button then works. I thought this is one
way of being able to make the code private and still available to be
executed.

Any thoughts?


Michael A.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top