Problem in temporary type toolbar

P

paresh

Hi,

My mail goal is to make sure that each and every outlook window must have
one and one add-in toolbar. The temporary type add-in toolbar works fine but
has below limitations:

1. If you hide or reposition the tool bar, it changes to default again
when you restart the outlook.
2. Possibility of missing or duplicat toolbar from/on outlook window. See
below example where toolbar can be missed.
-- Just open Outlook, you have "My button".
-- Then open Calender in new windows. Everything works fine.
-- Now close Outlook window first and then calender window.
-- Again open Outlook. It will open two windows Outlook and
Calender and you will have two toolbars on Outlook window and no toolbar on
calender window.

I tried with permanent type add-in toolbar also but facing other issues. see
https://www.microsoft.com/office/co...d5c-fd66c820f667&cat=&lang=en&cr=US&sloc=&p=1

Could any one please help me to sort out this issues.

Thanks.

==MY code ===

Option Explicit
Public out_appt As Outlook.Application
Public WithEvents MyButton As Office.CommandBarButton
Public MyCommandBar As Office.CommandBar
Public WithEvents myColExpl As Outlook.Explorers
Public WithEvents myExpl As Outlook.Explorer
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
Set out_appt = Application
End Sub
Private Sub AddinInstance_OnStartupComplete(custom() As Variant)
Set myColExpl = out_appt.Explorers
If out_appt.Explorers.Count > 0 Then
Call CreateToolBar
End If
Exit Sub
End Sub
Private Sub myColExpl_NewExplorer(ByVal Explorer As Outlook.Explorer)
If myExpl Is Nothing Then
Set myExpl = Explorer
End If
If out_appt.Explorers.Count > 0 Then
Call CreateToolBar
End If
End Sub
Private Sub myExpl_Close()
If out_appt.Explorers.Count < 1 Then
Set myExpl = Nothing
Set myColExpl = Nothing
End If
End Sub
Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
On Error Resume Next
MsgBox "button clicked"
End Sub
Private Sub CreateToolBar()
If out_appt.Explorers.Count = 0 Then
Exit Sub
End If
Set myExpl = out_appt.ActiveExplorer
Const TOOLBARNAME = "My Toolbar"

' Set MyCommandBar = myExpl.CommandBars.Item(TOOLBARNAME)
' If Not MyCommandBar Is Nothing Then
' MsgBox "exists"
' Exit Sub
' End If
'
Set MyCommandBar = myExpl.CommandBars.Add(TOOLBARNAME, msoBarTop, False,
True)
Set MyButton = MyCommandBar.Controls.Add(msoControlButton, , "890", ,
True)
With MyButton
.Caption = "&Foo Button"
.Enabled = True
.OnAction = "!<PermToolbarTesting.Connect>"
.Tag = "890"
.FaceId = 362
.Style = 3
.Visible = True
End With
MyCommandBar.Visible = True
End Sub
 
M

Michael Bauer [MVP - Outlook]

Why don't you test whether your toolbar exists already? And as to the
position, you need to store that anywhere, for instance, in the registry,
and reload it when you create the toolbar.

--
Best regards
Michael Bauer - MVP Outlook
Manage and share your categories:
<http://www.vboffice.net/product.html?pub=6&lang=en>


Am Tue, 15 Dec 2009 01:46:02 -0800 schrieb paresh:
 

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