Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5
This is the forum to discuss the Wrox book Professional Outlook 2007 Programming by Ken Slovak; ISBN: 9780470049945
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Outlook 2007 Programming ISBN: 978-0-470-04994-5 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 14th, 2007, 07:38 PM
Authorized User
Points: 457, Level: 7
Points: 457, Level: 7 Points: 457, Level: 7 Points: 457, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Burbank, CA, USA.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default Outlook 2007 Forms Programming ComboBox

Hello,

I need to make a combobox within a custom message form populate based on another combobox within the same form. I don't even know where to begin. It is the first time I've ever tried to write code for Outlook forms. If you can point me in the right direction, I'd appreciate it.

Thanks,
Arsi

*******(*)*******
__________________
*******(*)*******
Reply With Quote
  #2 (permalink)  
Old November 15th, 2007, 10:19 AM
Wrox Author
 
Join Date: Sep 2007
Location: Winter Park, Florida, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Where is the data for the combobox coming from and how do you want to base the contents of one on the other?

Do you need to store the resulting selections from the comboboxes in the form data so it's available at a later time?

Probably the best places to begin are at http://www.outlookcode.com/article.aspx?ID=35 for information about custom forms in general, http://www.outlookcode.com/article.aspx?id=32 for information on placing custom controls on Outlook forms, and the List and Combo Boxes section at the second URL for specific information and links about comboboxes.


Ken Slovak
Reply With Quote
  #3 (permalink)  
Old November 15th, 2007, 12:45 PM
Authorized User
Points: 457, Level: 7
Points: 457, Level: 7 Points: 457, Level: 7 Points: 457, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Burbank, CA, USA.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default

Hi Ken,

Thank you for the quick response. I'll look into the links you gave me. The data from the first combo box is static (hard coded). Actually, initially, I setup the entire form with the user interface (drag drop), but later the business logic was requested. The data for the second combo box may also be hard coded. Basically, when a user selects one value from the first combo box, the second combo box must be populated according to the selection.

Thank you for your help.

Arsi

*******(*)*******
Reply With Quote
  #4 (permalink)  
Old November 15th, 2007, 01:30 PM
Authorized User
Points: 457, Level: 7
Points: 457, Level: 7 Points: 457, Level: 7 Points: 457, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Burbank, CA, USA.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default

Hi Ken,

Thank you for the links, they've been very helpful. This is what I have right now:

Sub Item_CustomPropertyChange(ByVal Name)
    Dim SiteValue
    Set TheInspector = Item.GetInspector
    Set oPage = TheInspector.ModifiedFormPages("Message")
    Set oCtrl = oPage.Controls("cboSites")
    Set mCtrl = oPage.Controls("cboRoomReserved1")

    Select Case Name
        Case "cboSites"
        SiteValue = oCtrl.Value
        MsgBox "The Value is: " & SiteValue
        Select Case SiteValue
            Case "Bur"
                mCtrl.PossibleValues = "Board Room; Operations; Finance;"
        End Select
    End Select
End Sub

After Publishing the form and Running it, I get an error that says "Could not find the specified object: Line No. 5".

I have the control in the 3rd frame control of a set of 3 frame controls. Do I need to set these controls as well?

Thank you again,

Arsi

*******(*)*******
Reply With Quote
  #5 (permalink)  
Old November 15th, 2007, 02:27 PM
Wrox Author
 
Join Date: Sep 2007
Location: Winter Park, Florida, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

If the controls are all on the "Message" tab then to get cboSites you would use something like this if cboSites was in frame control fra1:

Set oCtrl = oPage.Controls("fra1").Controls("cboSites")

A couple of tips:

1. I'd move the Set lines inside the Case block so they are executed only if the user property is relevant.

2. CustomPropertyChange fires for your controls only if they are bound controls (bound to an Outlook.UserProperty). You must bind each combobox to a UserProperty so the event will fire.

3. The Name passed to CustomPropertyChange is the name of the UserProeprty the control is bound to, not the name of the user control. So if cboSites is bound to "userSites" then Name would be "userSites" in the Case tests. Same for the other combo.

4. Never use PossibleValues in code to set a combo. That is guaranteed to one-off the form, which is not good. Outlookcode.com has interesting information on the bad effects of one-offing, one of which is that your code will no longer run.


Ken Slovak
Reply With Quote
  #6 (permalink)  
Old November 15th, 2007, 02:30 PM
Wrox Author
 
Join Date: Sep 2007
Location: Winter Park, Florida, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I forgot to mention that instead of using PossibleValues use the AddItem method of the combo to add items to its list. Call Clear() first to clear it out, then add your entries using AddItem.

Ken Slovak
Reply With Quote
  #7 (permalink)  
Old November 15th, 2007, 03:00 PM
Authorized User
Points: 457, Level: 7
Points: 457, Level: 7 Points: 457, Level: 7 Points: 457, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Burbank, CA, USA.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default

Hi Ken,

Thanks again!
This is what I have now:

Sub Item_CustomPropertyChange(ByVal Name)
    Set TheInspector = Item.GetInspector
    Set oPage = TheInspector.ModifiedFormPages("Message")
    Select Case Name
        Case "cboSites"
        Dim SiteValue

          Set Frame1 = oPage.Controls("frmVCRequest")
            Set Frame2 = Frame1.Controls("frmVCSiteSelection")
            Set Frame3 = Frame2.Controls("frmSite1")
            Set oCtrl = Frame3.Controls("ComboBox1")
            Set mCtrl = Frame3.Controls("ComboBox7")

            SiteValue = oCtrl.Value

            Select Case SiteValue
                Case "Site 1"
                mCtrl.Clear()
                mCtrl.AddItem = "Room 7"
                mCtrl.AddItem = "Room 8"
                mCtrl.AddItem = "Room 9"
                mCtrl.AddItem = "Room 10"
                mCtrl.AddItem = "Room 11"
            Case "Site 2"
                mCtrl.Clear()
                mCtrl.AddItem = "Room 4"
                mCtrl.AddItem = "Room 5"
                mCtrl.AddItem = "Room 6"
            Case "Site 3"
                mCtrl.Clear()
                mCtrl.AddItem = "Room 1"
                mCtrl.AddItem = "Room 2"
                mCtrl.AddItem = "Room 3"
            Case Else
                mCtrl.AddItem = "N/A"
            End Select
    End Select
End Sub

At Line 19 I get an object does not support 'AddItem' error message. Both Combo boxes are bound. I got this code to work using 'PossibleValues', but since that's not the best way to do it, I'd like to get it to work with 'AddItem'. What am I doing wrong?

Thanks again,

Arsi

*******(*)*******
Reply With Quote
  #8 (permalink)  
Old November 15th, 2007, 03:06 PM
Authorized User
Points: 457, Level: 7
Points: 457, Level: 7 Points: 457, Level: 7 Points: 457, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Burbank, CA, USA.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default

Hi Ken,

I found the problem! I was writing mCtrl.AddItem = "Room 1" where it should have been mCtrl.AddItem "Room 1". Ooops!

Thank you so much!!!! :D

Arsi

*******(*)*******
Reply With Quote
  #9 (permalink)  
Old November 15th, 2007, 03:38 PM
Wrox Author
 
Join Date: Sep 2007
Location: Winter Park, Florida, USA.
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Default

So everything's working now? Good. You have to be careful with the syntax you use.

I've often found that it's far easier to get form code running initially by testing it in the Outlook VBA project. I can use fill object declarations with As clauses, get the benefits of real Help and Intellisense and get various other benefits. Once the code is debugged and running I convert it to VBScript code, which is very easy and port it to my forms.

Ken Slovak
Reply With Quote
  #10 (permalink)  
Old December 20th, 2007, 01:39 PM
Authorized User
Points: 457, Level: 7
Points: 457, Level: 7 Points: 457, Level: 7 Points: 457, Level: 7
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2004
Location: Burbank, CA, USA.
Posts: 95
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to Arsi
Default

Hi Ken, :)

Yes. Yes. It's me AGAIN! Well, I got the add-in to work correctly. Now I need to create a batch file to install it and everything that comes with it silently. This is what I have:

@echo off
rem ================================================== ===============
rem Silent Installation of MS Outlook Add-in
setup /qn /l*v \\server\directory 1\directory 2\directory 3\directory 4\install.log /i /a \\server\directory 1\directory 2\directory 3\directory 4\setup.exe
rem ================================================== ===============

I get the error message "Please go to the control panel to install & configure system components" when I double-click on the batch file. What do you think might be causing this?

Thanks!

Arsi

*******(*)*******
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
device DLL programming in client side programming hendyhanusin ASP.NET 1.0 and 1.1 Professional 2 February 19th, 2009 12:01 PM
device DLL programming in client side programming hendyhanusin ASP.NET 1.0 and 1.1 Basics 0 March 21st, 2007 08:05 AM
device DLL programming in client side programming hendyhanusin ASP.NET 2.0 Professional 1 March 21st, 2007 08:04 AM
Outlook programming, no GetNamespace DanRoche C# 2 July 27th, 2006 11:08 AM
Professional Outlook 2000 Programming Colinspurs Wrox Book Feedback 3 August 17th, 2004 10:32 AM



All times are GMT -4. The time now is 08:22 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.