Setting combobox properties from Outlook 2007 Add-in

Status
Not open for further replies.
P

paresh

Hi,

Could any one please help me with setting below properties for combobox

created on Outlook toolbar using Outlook 2007 Add-in. Please refer attached

initial code I wrote to create combobox in my Outlook command bar.

Could you tell me how to achieve below items:

1. When I select any "test" items from combobox the myComboBox_Click()

doesn't get called. Could you tell me what is wrong in the code?

2. How to add "FaceID" along with msoComboLabel properties? Basically I

want to have picture with the label name. I cannot use ".FaceID" as it gives

compile time error "method or data type not found". Could you help me on this.

Any help would be much appreciated.

My code:

' I have written below code in Connect.Dsr

' For your information, the similar methods work for CommandBarButton

Private WithEvents myComboBox As Office.CommandBarComboBox

Private Sub myComboBox_Click()

MsgBox "Combobox selection change event"

End Sub

Set mylComboBox = myCommandBar.Controls.Add(msoControlComboBox)

With myComboBox

> OnAction = "myComboBox_Click"

> Style = msoComboLabel

> AddItem "test1"

> AddItem "test2"

> AddItem "test3"

> Visible = True

End With

End If

Thanks.
 
If you are going to write Outlook and Office addins you really need to

become familiar with the object models you are working with. Try looking in

the Object Browser sometime.

There is no Click() event for a CommandBarComboBox control, and no support

for images. You can only do what the controls you are working with support.

"paresh" <paresh> wrote in message

news:2019CD69-6D15-4CF5-A9A5-68D8D521AF8D@microsoft.com...
> Hi,

> Could any one please help me with setting below properties for combobox
> created on Outlook toolbar using Outlook 2007 Add-in. Please refer
> attached
> initial code I wrote to create combobox in my Outlook command bar.

> Could you tell me how to achieve below items:

> 1. When I select any "test" items from combobox the myComboBox_Click()
> doesn't get called. Could you tell me what is wrong in the code?

> 2. How to add "FaceID" along with msoComboLabel properties? Basically I
> want to have picture with the label name. I cannot use ".FaceID" as it
> gives
> compile time error "method or data type not found". Could you help me on
> this.

> Any help would be much appreciated.

> My code:
> ' I have written below code in Connect.Dsr
> ' For your information, the similar methods work for CommandBarButton

> Private WithEvents myComboBox As Office.CommandBarComboBox

> Private Sub myComboBox_Click()
> MsgBox "Combobox selection change event"
> End Sub

> Set mylComboBox = myCommandBar.Controls.Add(msoControlComboBox)
> With myComboBox
> .OnAction = "myComboBox_Click"
> .Style = msoComboLabel
> .AddItem "test1"
> .AddItem "test2"
> .AddItem "test3"
> .Visible = True
> End With
> End If

> Thanks.
 
Thanks a lot Ken. That was the precise answer. I looked into Object browser

and then only I have posted this question but now I realized that I looked in

VB Combobox and not CommandBarComboBox.

I am curious then is there any way to create VB combobox on Outlook toolbar?

I want to handle click event and need some small gif images inside that.

If it is possible in any aspects, I would be fine.

Thanks for being there.

Paresh
wrote:


> If you are going to write Outlook and Office addins you really need to
> become familiar with the object models you are working with. Try looking in
> the Object Browser sometime.

> There is no Click() event for a CommandBarComboBox control, and no support
> for images. You can only do what the controls you are working with support.

> >

>

> "paresh" <paresh> wrote in message
> news:2019CD69-6D15-4CF5-A9A5-68D8D521AF8D@microsoft.com...
> > Hi,
> > Could any one please help me with setting below properties for combobox
> > created on Outlook toolbar using Outlook 2007 Add-in. Please refer
> > attached
> > initial code I wrote to create combobox in my Outlook command bar.
> > Could you tell me how to achieve below items:
> > 1. When I select any "test" items from combobox the myComboBox_Click()
> > doesn't get called. Could you tell me what is wrong in the code?
> > 2. How to add "FaceID" along with msoComboLabel properties? Basically I
> > want to have picture with the label name. I cannot use ".FaceID" as it
> > gives
> > compile time error "method or data type not found". Could you help me on
> > this.
> > Any help would be much appreciated.
> > My code:
> > ' I have written below code in Connect.Dsr
> > ' For your information, the similar methods work for CommandBarButton
> > Private WithEvents myComboBox As Office.CommandBarComboBox
> > Private Sub myComboBox_Click()
> > MsgBox "Combobox selection change event"
> > End Sub
> > Set mylComboBox = myCommandBar.Controls.Add(msoControlComboBox)
> > With myComboBox
> > .OnAction = "myComboBox_Click"
> > .Style = msoComboLabel
> > .AddItem "test1"
> > .AddItem "test2"
> > .AddItem "test3"
> > .Visible = True
> > End With
> > End If
> > Thanks.


>
 
The other thing is below method doesn't work either. It gives compile time

error "The procedure declaration doesnt match description of event or

prcedure having the same name". Could you please tell me what is wrong here?

Sub myCombobox_Change(Ctrl As Office.CommandBarComboBox)

MsgBox "Combobox selection changed"

End Sub

Thanks.
wrote:


> If you are going to write Outlook and Office addins you really need to
> become familiar with the object models you are working with. Try looking in
> the Object Browser sometime.

> There is no Click() event for a CommandBarComboBox control, and no support
> for images. You can only do what the controls you are working with support.

> >

>

> "paresh" <paresh> wrote in message
> news:2019CD69-6D15-4CF5-A9A5-68D8D521AF8D@microsoft.com...
> > Hi,
> > Could any one please help me with setting below properties for combobox
> > created on Outlook toolbar using Outlook 2007 Add-in. Please refer
> > attached
> > initial code I wrote to create combobox in my Outlook command bar.
> > Could you tell me how to achieve below items:
> > 1. When I select any "test" items from combobox the myComboBox_Click()
> > doesn't get called. Could you tell me what is wrong in the code?
> > 2. How to add "FaceID" along with msoComboLabel properties? Basically I
> > want to have picture with the label name. I cannot use ".FaceID" as it
> > gives
> > compile time error "method or data type not found". Could you help me on
> > this.
> > Any help would be much appreciated.
> > My code:
> > ' I have written below code in Connect.Dsr
> > ' For your information, the similar methods work for CommandBarButton
> > Private WithEvents myComboBox As Office.CommandBarComboBox
> > Private Sub myComboBox_Click()
> > MsgBox "Combobox selection change event"
> > End Sub
> > Set mylComboBox = myCommandBar.Controls.Add(msoControlComboBox)
> > With myComboBox
> > .OnAction = "myComboBox_Click"
> > .Style = msoComboLabel
> > .AddItem "test1"
> > .AddItem "test2"
> > .AddItem "test3"
> > .Visible = True
> > End With
> > End If
> > Thanks.


>
 
Normally that's not possible. Add-In Express lets you use controls that are

managed code controls such as a combo, but only if you use their framework.

They are using Win32 API hacks to put things where they want them and then

using message hooks to listen for events on those controls. Otherwise you

just have to use what you are given.

"paresh" <paresh> wrote in message

news:A57483DE-4307-4E72-BF20-918AB6BD154E@microsoft.com...
> Thanks a lot Ken. That was the precise answer. I looked into Object
> browser
> and then only I have posted this question but now I realized that I looked
> in
> VB Combobox and not CommandBarComboBox.

> I am curious then is there any way to create VB combobox on Outlook
> toolbar?
> I want to handle click event and need some small gif images inside that.

> If it is possible in any aspects, I would be fine.

> Thanks for being there.
> Paresh
 
The event handler signature looks OK, but that should be automatic in VB6 if

you declared myCombobox WithEvents.

"paresh" <paresh> wrote in message

news:85280AB1-6B24-4927-90D2-41D11DB3A8E4@microsoft.com...
> The other thing is below method doesn't work either. It gives compile time
> error "The procedure declaration doesnt match description of event or
> prcedure having the same name". Could you please tell me what is wrong
> here?

> Sub myCombobox_Change(Ctrl As Office.CommandBarComboBox)
> MsgBox "Combobox selection changed"
> End Sub

> Thanks.
 
Ken, please refer my complete code given below. It gives the same error.

Private WithEvents myComboBox As Office.CommandBarComboBox

Sub myComboBox_Change(Ctrl As Office.CommandBarComboBox)

MsgBox "Combobox selection changed"

End Sub

Set myComboBox myCommandBar.Controls.Add(msoControlComboBox)

With myComboBox

> BeginGroup = True

> Caption = "Test"

> Enabled = True

> OnAction = "myComboBox_Change"

> Style = msoComboLabel

> AddItem "Test1"

> AddItem "Test2"

> AddItem "Test3"

> Visible = True

End With

When I change myComboBox_Change event to just Change event, it doesnt give

that error but doesn't work either. When I select the "Test1" from combobox,

it doest print my message box.

Sub Change(Ctrl As Office.CommandBarComboBox)

MsgBox "Combobox selection changed"

End Sub

Could you please tell me what could be wrong here?

Thanks, Paresh
wrote:


> The event handler signature looks OK, but that should be automatic in VB6 if
> you declared myCombobox WithEvents.

> >

>

> "paresh" <paresh> wrote in message
> news:85280AB1-6B24-4927-90D2-41D11DB3A8E4@microsoft.com...
> > The other thing is below method doesn't work either. It gives compile time
> > error "The procedure declaration doesnt match description of event or
> > prcedure having the same name". Could you please tell me what is wrong
> > here?
> > Sub myCombobox_Change(Ctrl As Office.CommandBarComboBox)
> > MsgBox "Combobox selection changed"
> > End Sub
> > Thanks.


>
 
The below worked.

Private Sub myComboBox_Change(ByVal Ctrl As Office.CommandBarComboBox)

Please note the ByVal word.

Thanks.

"paresh" wrote:


> Ken, please refer my complete code given below. It gives the same error.

> Private WithEvents myComboBox As Office.CommandBarComboBox

> Sub myComboBox_Change(Ctrl As Office.CommandBarComboBox)
> MsgBox "Combobox selection changed"
> End Sub

> Set myComboBox myCommandBar.Controls.Add(msoControlComboBox)
> With myComboBox
> .BeginGroup = True
> .Caption = "Test"
> .Enabled = True
> .OnAction = "myComboBox_Change"
> .Style = msoComboLabel
> .AddItem "Test1"
> .AddItem "Test2"
> .AddItem "Test3"
> .Visible = True
> End With

> When I change myComboBox_Change event to just Change event, it doesnt give
> that error but doesn't work either. When I select the "Test1" from combobox,
> it doest print my message box.

> Sub Change(Ctrl As Office.CommandBarComboBox)
> MsgBox "Combobox selection changed"
> End Sub

> Could you please tell me what could be wrong here?

> Thanks, Paresh

> " - " wrote:
>
> > The event handler signature looks OK, but that should be automatic in VB6 if
> > you declared myCombobox WithEvents.
> > > >

> >

> > "paresh" <paresh> wrote in message
> > news:85280AB1-6B24-4927-90D2-41D11DB3A8E4@microsoft.com...
> > > The other thing is below method doesn't work either. It gives compile time
> > > error "The procedure declaration doesnt match description of event or
> > > prcedure having the same name". Could you please tell me what is wrong
> > > here?
> > > > Sub myCombobox_Change(Ctrl As Office.CommandBarComboBox)
> > > MsgBox "Combobox selection changed"
> > > End Sub
> > > > Thanks.

> >
 
In VBA/VB the default is ByRef, I guess it didn't like that implicit ByRef

and wanted a ByVal. Good detective work.

I haven't used that control very often in toolbars, it's just too funky in

how it works for my taste.

"paresh" <paresh> wrote in message

news:EDB279D8-EEBE-4960-8CBD-941945D23DA2@microsoft.com...
> The below worked.

> Private Sub myComboBox_Change(ByVal Ctrl As Office.CommandBarComboBox)

> Please note the ByVal word.

> Thanks.
 
Yes Ken, you are correct. I have wasted two days in that simple "ByVal" Word :)

Thanks, Paresh
wrote:


> In VBA/VB the default is ByRef, I guess it didn't like that implicit ByRef
> and wanted a ByVal. Good detective work.

> I haven't used that control very often in toolbars, it's just too funky in
> how it works for my taste.

> >

>

> "paresh" <paresh> wrote in message
> news:EDB279D8-EEBE-4960-8CBD-941945D23DA2@microsoft.com...
> > The below worked.
> > Private Sub myComboBox_Change(ByVal Ctrl As Office.CommandBarComboBox)
> > Please note the ByVal word.
> > Thanks.


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
V Setting up Outlook 2021 on new computer Using Outlook 2
AlphonseG Outlook 365 Outlook Crashes on setting SaveSentMessageFolder Outlook VBA and Custom Forms 4
R Outlook 2021 Having problem setting up outlook 2021 with windows 11. I have 3 gmail accounts and I want the 3 gmail, emails to merge into the same outlook input. Using Outlook.com accounts in Outlook 0
e_a_g_l_e_p_i Outlook 2010 Help setting up Gmail account in Outlook 2010 Using Outlook 3
P OWA Settings->Calendar->Events from Email; Setting changes do not hold Using Outlook 1
Marc2019 Setting up an Outlook Account on Mac Os 10.6.8 Outlook 2011 Using Outlook 1
L Outlook Office 365 client: won't remember my setting File, not to collapse ribbon Using Outlook 2
M Where is the setting to *turn off* open calendar in a new window? Using Outlook 3
llama_thumper Setting up forwarders on Exchange server Exchange Server Administration 0
B Setting rules Using Outlook 1
C iCloud Setting missing Outlook tab and Outlook missing the iCloud refresh button Using Outlook 4
B Setting defaults Using Outlook 2
C need help setting up outlook first time Using Outlook 1
P Reading Pane (Reading Pain?) Default Setting Using Outlook 1
W Setting up a custom form Outlook VBA and Custom Forms 2
mctabish Setting "Reply To" based on inbox Outlook VBA and Custom Forms 2
R Setting font and color used when replying to an email Outlook VBA and Custom Forms 3
M Setting flag follow up for next business day Outlook VBA and Custom Forms 1
Ed Sheehan Unusual behaviour in setting Sender (Outlook 2016) Outlook VBA and Custom Forms 4
Jennifer Murphy Equations don't comply with style setting to left justify Using Outlook 0
J Setting default address book Using Outlook 0
N Does a Shared Folder Policy override a Digital Signature Setting for macros? Outlook VBA and Custom Forms 6
Diane Poremsky Setting up an Outlook.com IMAP account Using Outlook 0
Diane Poremsky Setting the default Country for Outlook Contacts Using Outlook 0
H Need help setting up GetFolderPath-Makro with Vodafone IMAP Mail-Account Outlook VBA and Custom Forms 0
Diane Poremsky Adjusting Outlook's Zoom setting in Email Using Outlook 0
O Setting default format for composing/replying to emails Using Outlook 3
B Outlook Calendar/setting appointments Using Outlook 1
Diane Poremsky Adjusting Outlook's Zoom setting in Email Using Outlook 0
Diane Poremsky Setting Custom Reminder Times Using Outlook 0
A Can't stop Outlook.com from setting reminders on appointments? Using Outlook.com accounts in Outlook 3
A Setting RULES with more than one condition in MS OUTLOOK Using Outlook 6
L Setting up my PA's Outlook Using Outlook 7
E Need Help on Setting up a repeated Reminder on Task with Reoccurence Every Year Using Outlook 6
N "Instant Search" setting a default view Using Outlook 3
H SETTING UP A "NEW" NEVER HAD NEVER USED EMAIL ACCOUNT Using Outlook 9
K Setting Default Email Address for Meeting Replies Using Outlook 3
S Setting up Outlook 2010 to work with custom domain outlook.com account BCM (Business Contact Manager) 3
D Setting defult "Show a room list" Using Outlook 0
Horsepower Setting appointments in calendar Using Outlook 3
J Setting tabs in contacts / notes field Using Outlook 0
T Setting a Default Subject from a certain Signature Using Outlook 0
K Help Needed - setting up Email in Outlook 2013 Using Outlook 3
mikecox setting Default area code in Contacts Using Outlook 5
G Outlook2013 - "From" name doesn't change even when changed in Account Setting Using Outlook 4
D How do I start completely from scratch in setting up Outlook 2013? Using Outlook 6
V View zoom setting changing Using Outlook 1
C Setting up Outlook 10 on Widows 8 using Google Server Using Outlook 3
I Outlook Appointments - Setting default text in message body Using Outlook 3
T Setting Color codes for each user of a shared Calendar Using Outlook 1

Similar threads

Back
Top