Results 1 to 2 of 2

Thread: HowTo: add a button to Outlook tool bar

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2002
    Location
    Dallas Texas
    Posts
    28

    Smile HowTo: add a button to Outlook tool bar

    how can I add a custom Button to the outlook tool bar and make it shell my app?

  2. #2
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    What I know: BUT its not the full answer.

    Adding a button to Outlook is not as easy as to Word, Excel and PowerPoint, as the “CommandBar” object doesn’t exist in the same way. Instead, the following method has been used successfully – unfortunately this has to be done manually by each user.

    · Right click on the toolbar, and choose customise (or View menu, Toolbars, Customise).
    · On the Commands tab, drag and drop a button to the tool bar at the top of the screen.
    · With the new button on the toolbar still selected, choose "Modify Selection".
    · Change the Name to "Registered Files" (or "Testing" or "Another Button").
    · In Modify Selection, "Change Button Image", and choose one of the pictures available.
    · In Modify Selection, select "Default Style". Close the Customise window.
    · In Modify Selection, select Assign HyperLink, select Open, then browse to the application required.

    Other techniques are available, for example:
    · Using an Outlook Add-In allows an external application (.DLL) to register itself with Outlook, and to be called when Outlook starts. Once the correct technique is found (!), this should be able to add a button.
    · The Virus checkers have tended to add themselves as a .DLL, using the MS-Mail technique. See the registry entry:
    Hkey_Local_Machine\Software\Microsoft\Exchange\Client\Extensions
    · Posible code for button adding:
    VB Code:
    1. Dim oOutlook As Object
    2. Dim MyBar As CommandBar
    3. Dim WithEvents MyButton As Office.CommandBarButton
    4. Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As Object, custom() As Variant)
    5.     On Error GoTo ErrHandler
    6.     Set oOutlook = Application.ActiveExplorer
    7.     Set MyBar = oOutlook.CommandBars.Add(Name:="MYBAR", Position:=msoBarTop, Temporary:=True)
    8.     Set MyButton = MyBar.Controls.Add(1)
    9.     MyBar.Visible = True
    10.     With MyButton
    11.         .Caption = "THE BUTTON"
    12.         .Style = msoButtonCaption
    13.         .Visible = True
    14.     End With
    15.     MsgBox "loaded"
    16.     Exit Sub
    17. ErrHandler:
    18.     MsgBox Err.Description & " : " & Err.Number
    19.     Set oOutlook = Nothing
    20.     Set MyButton = Nothing
    21. End Sub
    22.  
    23. Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
    24.     On Error Resume Next
    25.     MyButton.Delete
    26.     Set MyButton = Nothing
    27.     Set oOutlook = Nothing
    28. End Sub
    29.  
    30. Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, CancelDefault As Boolean)
    31.     MsgBox "eureka!"
    32. End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width