LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default Run an Add-in

Here's some code I wrote based on the links Tom provided. I've got exactly
the same issue as you. You should be able to copy this into your .xla
module. The user would have to manually run the "AddMenuButton" macro using
the Tools...Macro menu item. (The macro won't show up in the list, but the
macro can still be run.) You could probably trigger an automatic load using
the tips provided by Randy.

=======================

Sub AddMenuButton()

'Creates a command button on the Standard toolbar

Dim mCaption As String
Dim objCommandBar As Office.CommandBar
Dim objCommandBarControl As Office.CommandBarControl
Dim objCommandBarButton As Office.CommandBarButton

mCaption = "Button Text"

Set objCommandBar = Application.CommandBars("Standard")

For Each objCommandBarControl In
Application.CommandBars("Standard").Controls
If objCommandBarControl.Caption = mCaption Then
objCommandBarControl.Delete
Next objCommandBarControl

With objCommandBar.Controls

Set objCommandBarButton = .Add(msoControlButton)

With objCommandBarButton

.Caption = mCaption
.Style = msoButtonCaption
.TooltipText = "Bring up the CPS PV Export control form"
.OnAction = "DisplayForm"
End With

End With

End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"