vb6 dll issues - adding popup to menu bar and calling form

G

Guest

Bit of a crucial problem..

I have tried several different ways to add a popup menu to the Outlook XP Menu Bar, with a button off that which calls a form. This needs to be districuted to 700 users, so the VBAProject.OTM option (which was my initial one) is out

Using a com add-in, I can get as far as adding the popup menu, and the button. When I use ".OnAction = frmConflictCheck.show", it automatically calls the form when Outlook initialises, not just when the button is clicked

My 2 bits of the VB project are the Outlook Designer (Connect.Dsr) and the form (frmConflictCheck)

My general declarations are
================================
Implements IDTExtensibility

Dim WithEvents oApp As Outlook.Applicatio
Dim WithEvents oNS As Outlook.NameSpac
Dim WithEvents oExplorer As Outlook.Explore
================================

The code I'm using in IDTExtensibility2_OnStartupComplete is
================================
Private Sub IDTExtensibility2_OnStartupComplete(
custom() As Variant

On Error Resume Nex
Dim colCB As Office.CommandBar
Dim objCB As Office.CommandBa
Dim objCBMenu As Office.CommandBarPopu
Dim objCBMenuCB As Office.CommandBa
Dim objCBB As Office.CommandBarButto
Dim objPicture As stdole.IPictureDis

'Const strPic As String = "C:\temp\ConflictCheck\mail01.bmp

Set oApp = CreateObject("Outlook.Application"
Set colCB = oApp.ActiveExplorer.CommandBar
Set objCB = colCB.Item("Menu Bar"

MsgBox ("Allan Initialising..."

If objCB.Controls.Item(7).Caption = "Ma&sons" The

objCB.Controls.Item(7).Delet

MsgBox ("Allan Deleted Menu..."

Els

Set objCBMenu = objCB.Controls.Add(Type:=msoControlPopup,
Before:=7, Temporary:=True
With objCBMen
.Caption = "Ma&sons
Set objCBMenuCB = .CommandBa
Set objCBB = objCBMenuCB.Controls.Add(Type:=msoControlButton,
Temporary:=True
objCBB.Caption = "&Conflict Check

'Set objPicture = LoadPicture(strPic
'objCBB.Picture = objPictur
'objCBB.Picture = LoadPicture("c:\temp\conflictcheck\mail01.bmp"

objCBB.OnAction = frmConflictCheck.Sho

End Wit

MsgBox ("Allan Added Menu..."

Set oApp = Nothin
Set colCB = Nothin
Set objCB = Nothin
Set objCBMenu = Nothin
Set objCBMenuCB = Nothin
Set objCBB = Nothin

End I

End Su
==================================

What am I missing?! My secondar problem, which you'll be able to see in the code above, is that I can't, for the life of me, assign the picture property to the button..

ANY help at all will be HUGELY appreciated..
Allan
 
G

Guest

I'm still having problems with this - is there no one who can help me
Alla

----- allan rees-bevan wrote: ----

Bit of a crucial problem..

I have tried several different ways to add a popup menu to the Outlook XP Menu Bar, with a button off that which calls a form. This needs to be districuted to 700 users, so the VBAProject.OTM option (which was my initial one) is out

Using a com add-in, I can get as far as adding the popup menu, and the button. When I use ".OnAction = frmConflictCheck.show", it automatically calls the form when Outlook initialises, not just when the button is clicked

My 2 bits of the VB project are the Outlook Designer (Connect.Dsr) and the form (frmConflictCheck)

My general declarations are
================================
Implements IDTExtensibility

Dim WithEvents oApp As Outlook.Applicatio
Dim WithEvents oNS As Outlook.NameSpac
Dim WithEvents oExplorer As Outlook.Explore
================================

The code I'm using in IDTExtensibility2_OnStartupComplete is
================================
Private Sub IDTExtensibility2_OnStartupComplete(
custom() As Variant

On Error Resume Nex
Dim colCB As Office.CommandBar
Dim objCB As Office.CommandBa
Dim objCBMenu As Office.CommandBarPopu
Dim objCBMenuCB As Office.CommandBa
Dim objCBB As Office.CommandBarButto
Dim objPicture As stdole.IPictureDis

'Const strPic As String = "C:\temp\ConflictCheck\mail01.bmp

Set oApp = CreateObject("Outlook.Application"
Set colCB = oApp.ActiveExplorer.CommandBar
Set objCB = colCB.Item("Menu Bar"

MsgBox ("Allan Initialising..."

If objCB.Controls.Item(7).Caption = "Ma&sons" The

objCB.Controls.Item(7).Delet

MsgBox ("Allan Deleted Menu..."

Els

Set objCBMenu = objCB.Controls.Add(Type:=msoControlPopup,
Before:=7, Temporary:=True
With objCBMen
.Caption = "Ma&sons
Set objCBMenuCB = .CommandBa
Set objCBB = objCBMenuCB.Controls.Add(Type:=msoControlButton,
Temporary:=True
objCBB.Caption = "&Conflict Check

'Set objPicture = LoadPicture(strPic
'objCBB.Picture = objPictur
'objCBB.Picture = LoadPicture("c:\temp\conflictcheck\mail01.bmp"

objCBB.OnAction = frmConflictCheck.Sho

End Wit

MsgBox ("Allan Added Menu..."

Set oApp = Nothin
Set colCB = Nothin
Set objCB = Nothin
Set objCBMenu = Nothin
Set objCBMenuCB = Nothin
Set objCBB = Nothin

End I

End Su
==================================

What am I missing?! My secondar problem, which you'll be able to see in the code above, is that I can't, for the life of me, assign the picture property to the button..

ANY help at all will be HUGELY appreciated..
Allan
 
S

Sue Mosher [MVP-Outlook]

OnAction needs to use the ProgID of the application. The Items Command Bar
sample from the Resources section at http://www.microeye.com is the basic
primer on how to set of custom toolbar buttons and menus. This sample will
also show you how to make sure your add-in shuts down properly when Outlook
shuts down.

As for the picture, what version of Outlook?
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



allan rees-bevan said:
Bit of a crucial problem...

I have tried several different ways to add a popup menu to the Outlook XP
Menu Bar, with a button off that which calls a form. This needs to be
districuted to 700 users, so the VBAProject.OTM option (which was my initial
one) is out.
Using a com add-in, I can get as far as adding the popup menu, and the
button. When I use ".OnAction = frmConflictCheck.show", it automatically
calls the form when Outlook initialises, not just when the button is
clicked.
My 2 bits of the VB project are the Outlook Designer (Connect.Dsr) and the form (frmConflictCheck).

My general declarations are:
=================================
Implements IDTExtensibility2

Dim WithEvents oApp As Outlook.Application
Dim WithEvents oNS As Outlook.NameSpace
Dim WithEvents oExplorer As Outlook.Explorer
=================================

The code I'm using in IDTExtensibility2_OnStartupComplete is:
=================================
Private Sub IDTExtensibility2_OnStartupComplete( _
custom() As Variant)

On Error Resume Next
Dim colCB As Office.CommandBars
Dim objCB As Office.CommandBar
Dim objCBMenu As Office.CommandBarPopup
Dim objCBMenuCB As Office.CommandBar
Dim objCBB As Office.CommandBarButton
Dim objPicture As stdole.IPictureDisp

'Const strPic As String = "C:\temp\ConflictCheck\mail01.bmp"

Set oApp = CreateObject("Outlook.Application")
Set colCB = oApp.ActiveExplorer.CommandBars
Set objCB = colCB.Item("Menu Bar")

MsgBox ("Allan Initialising...")

If objCB.Controls.Item(7).Caption = "Ma&sons" Then

objCB.Controls.Item(7).Delete

MsgBox ("Allan Deleted Menu...")

Else

Set objCBMenu = objCB.Controls.Add(Type:=msoControlPopup, _
Before:=7, Temporary:=True)
With objCBMenu
.Caption = "Ma&sons"
Set objCBMenuCB = .CommandBar
Set objCBB = objCBMenuCB.Controls.Add(Type:=msoControlButton, _
Temporary:=True)
objCBB.Caption = "&Conflict Check"

'Set objPicture = LoadPicture(strPic)
'objCBB.Picture = objPicture
'objCBB.Picture = LoadPicture("c:\temp\conflictcheck\mail01.bmp")

objCBB.OnAction = frmConflictCheck.Show

End With

MsgBox ("Allan Added Menu...")

Set oApp = Nothing
Set colCB = Nothing
Set objCB = Nothing
Set objCBMenu = Nothing
Set objCBMenuCB = Nothing
Set objCBB = Nothing

End If

End Sub
===================================

What am I missing?! My secondar problem, which you'll be able to see in
the code above, is that I can't, for the life of me, assign the picture
property to the button...
 
C

Catalys

Hi TildeX,

Your code is following your instructions: frmConflictCheck.Show wil
always bring up the form whether or not it is tied to a butto
command.
The OnAction method calls for a string representing a function. (Se
below).

Set cbc = cbNewPopMenu.Controls.Add(Temporary:=True)
With cbc
.Caption = "New Conflict"
.OnAction = "ShowConflictCheck"
End With

Sub ShowConflictCheck()

Set fdrAll = GetNamespace("MAPI").Folders(cst1).Folders(cst2)
Set exp = fdrAll.GetExplorer
Set cbMain = exp.CommandBars("Menu Bar")
'Ref & run existing "New Conflict" command at
'bottom of the Actions menu:
Set cbcMenuPop = cbMain.FindControl(ID:=xxxx)

cbcMenuPop.Controls(xx).Execute

End su
 
U

Uwe

Hello,
i found that you need to have a bitmap of size 16x16 and you need to
assign the mask property too.

Regards
Uwe
 

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