Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Publisher / Programming / July 2005

Tip: Looking for answers? Try searching our database.

How do I add a Button to a toolbar that will run a macro/procedure

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boogie La La - 21 Jul 2005 12:20 GMT
Either I'm going mad - or I'm stupid!!

I go to customize, but in the category list 'Macros' is not there!!
Mary Sauer - 21 Jul 2005 18:29 GMT
When you customize, click the Tools category on the left, scroll down to Macros on
the right and drag it to the toolbar.

Signature

Mary Sauer MSFT MVP
http://office.microsoft.com/
http://msauer.mvps.org/
news://msnews.microsoft.com

> Either I'm going mad - or I'm stupid!!
>
> I go to customize, but in the category list 'Macros' is not there!!
Ed Bennett - 21 Jul 2005 19:53 GMT
Mary Sauer <gsauer@mycolumbus.rr.com> was very recently heard to utter:
> When you customize, click the Tools category on the left, scroll down
> to Macros on the right and drag it to the toolbar.

OP was looking for the Macros category on the left, which would give access
to all the available macros in the right-hand pane, as is available in other
Office applications.

Signature

Ed Bennett - MVP Microsoft Publisher

Ed Bennett - 21 Jul 2005 19:53 GMT
> Either I'm going mad - or I'm stupid!!

Here's some code I posted almost exactly two years ago to this group:

===
Public WithEvents cbbButton As Office.CommandBarButton

Sub Dummy()
   MsgBox "Dummy"
End Sub

Private Sub cbbButton_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
   Dummy
End Sub

Private Sub Document_BeforeClose(Cancel As Boolean)
   cbbButton.Delete
End Sub

Private Sub Document_Open()
   Dim cbBar As Office.CommandBar
   On Error Resume Next
   Set cbBar = Publisher.CommandBars("Macros")
   If Err.Number = 0 Then
       'everything is fine
   Else
       Set cbBar = Publisher.CommandBars.Add("Macros")
       Err.Clear
   End If
   Set cbbButton = cbBar.Controls(msoControlButton)
   If Err.Number = 0 Then
       'everything is fine
   Else
       Set cbbButton = cbBar.Controls.Add(msoControlButton)
   End If
   Err.Clear
   'you can insert some code to format the button here
End Sub
===

This creates a new button on a toolbar named "Macros", and calls the Dummy
subroutine.

Signature

Ed Bennett - MVP Microsoft Publisher


Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.