More Outlook Resource Sites

Microsoft Developer Network (MSDN)

FAQs and other general resources

forum 23-May-2019 09:51

Looking for help with Outlook programming projects — VSTO, add-ins, VBA, custom Outlook forms, etc.? You′ve come to the right place!

NEW! >> Subscribe to this site via RSS. For more RSS options, see the complete list of feeds on our main news page.

    Page [ 1 ]  
 Outlook Form Design Printer Friendly Version
Designing custom Outlook forms and form regions and writing code for them
More fun with Keywords
Hi Sue, I like the new skin, it has a more professional look and feel.

I am using a keywords field in a form again (!). This is to store departments within the company who have been allocated a proportion of the cost. It works in the background so the user cant see it. They just enter a % in one or more fields and the custompropertychange sets the appropriate member of the "Selected" collection of the list box to true. The list box being bound to my keywords field.

I have done this because I like the way you can group by the individual elements of a keywords field in a folder view. Very easy for a particular department to view all those they have a cost for.

My problem is that allthough setting the olist.Selected(i) = True does visibly make the selection appear and the control is bound it doesnt actually change the value of the bound field!! Strange but true.

Is ther another way to programtically add to the selected keywords?

  15-May-2007  04:54
  15-May-2007  05:03   
I am sure the new functionality is good too, I didnt mean to imply it was just the UI you updated.
  15-May-2007  06:34   
I am doing it again, answering my own question.

Using a text box as a mediator (binding the text box to the field) for a keywords field gives you two ways of manipulating it. either manipulate the string value using instr or put it in an array using split. I am not sure if this is the most eloquent but here is my string based solution.

The premise is that sname is the name of a numerical custom field that has just been changed as well as the keyword you want to add/remove. It is trigered by Item_CustomProprtyChange

sub SetSite(sname)
dim oText
dim sText
Set oText = item.getinspector.modifiedformpages _(tabsettings).controls("txtAllocate")
sText = oText.Value
'If it is already selected
If instr(sText, sname) > 0 then
  'If the triger field is 0 then remove it
  If userProperties(sName).Value = 0 then
    'Also remove the separator if found
    sText = Replace(stext, sname & ";", "")
    stext = Replace(stext, sname, "")
  End If
  'Keyword not already selected
  If UserProperties(sname).value > 0 then
    If len(stext)> 0 then
      'Include a separator
      stext = stext & ";" & sname
       'Sole Selection
       sText = sname
     End if
  End if
End if
oText.Value = stext
End sub

  15-May-2007  06:51   
That's a clever solution! I've sometimes been so frustrated with these little devils that I've resorted to an unbound list box. I like your way better.

Glad you like the new look. Play around with the My OutlookCode and Manage My Settings features on the home page.
  28-Dec-2010  08:14   
I want to find an attachment with a specfic name in email and if that specific name is found i want to send email.How to do that?
For Example: I received an email with an attachment named "Sample.txt".Now i want to write a code to verify if the opened email if having the name "Sample.txt",if it founds that name then it should send an email.
    Page [ 1 ]