How to Select Contact’s Company from a Predefined List Other than Typing Manually

As usual, when filling in the company field of a contact in Outlook, you need to type the company name manually. This article will teach you how to select contact’s company from a predefined list other than typing manually.

In general, when you fill in the company field of a contact in Outlook, you need type the company name manually. However, if the contacts in your Outlook are commonly from some specific companies, you must have a list of frequently-used company names. In this case, why don’t you directly select a company from this list other than inputting it manually? In the followings, we will teach you how to create a custom form containing the list of your frequently-used companies and then use VBA codes to enable this user form.

Select Contact's Company from a Predefined List Other than Typing Manually

Select Contact’s Company from a Predefined List Other than Typing Manually

  1. To start with, launch your Outlook program.
  2. Then press “Alt + F11” key buttons to open Outlook VBA editor.
  3. Next click “Insert” and select “UserForm”.Insert a UserForm
  4. Then hit the “ComboBox” button and then drag and drop in the UserForm1 to insert a custom combo box.Insert a custom combo box
  5. Next right click on the combo box and select “View Code”.View Code
  6. Subsequently, copy the following VBA code into the new project window.
Private Sub UserForm_Initialize()
    With ComboBox1
         'Change the company names as per your own case
         .AddItem "DataNumen,Inc."
         .AddItem "Microsoft,Inc."
         .AddItem "IBM,Inc."
         .AddItem "HP,Inc."
    End With
End Sub

Private Sub CommandButton1_Click()
    lSelectedItemIndex = ComboBox1.ListIndex
    Unload Me
End Sub

VBA Code - Define UserForm1

  1. Next double click on the “UserForm1”.
  2. After that, hit the “CommandButton” button in “Toolbox” and then drag and drop in the UserForm1 to insert a command button.Insert a command button
  3. Subsequently, click on the new button and change its caption to “OK” in the “Properties – CommandButton1”.Change Button Caption
  4. Then, pitch on the “UserForm1” and change its caption to “Select Company”.Change UserForm Caption
  5. Next, you should open a new module and copy the following VBA code into it.
Public lSelectedItemIndex As Long

Public Sub SelectCompany()
    Dim objContact As Outlook.ContactItem
 
    Set objContact = Outlook.Application.ActiveInspector.CurrentItem
 
    UserForm1.Show
 
    Select Case lSelectedItemIndex
           Case -1
                objContact.CompanyName = ""
           '0 refers to the first item in the drop down list
           Case 0
                objContact.CompanyName = "DataNumen,Inc."
           '1 refers to the second one
           Case 1
                objContact.CompanyName = "Microsoft,Inc."
           Case 2
                objContact.CompanyName = "IBM,Inc."
           Case 3
                objContact.CompanyName = "HP,Inc."
    End Select
End Sub

VBA Code - Select Contact's Company from a Predefined List

  1. After that, add the new macro to the Quick Access Toolbar of contact window.
  2. Later change your Outlook macro security level to low.
  3. Eventually, you can have a try.
  • Open a new contact.
  • And then click the new macro button in Quick Access Toolbar.
  • Next the user form will display.
  • You can select a company from the drop down list.
  • After selecting one, click “OK”.Select Contact's Company from a Predefined List
  • At once, the company will be filled into the company field in the contact.

Escape from PST Data Corruption

Though Outlook offers users a great number of functions, you still have to spend a lot of efforts to prevent PST errors and corruption. For instance, it is suggested to safeguard your PST file against virus or malware attacks. Moreover, you have to back up your PST data regularly, which will contribute a lot to future Outlook recovery when you encounter PST corruption.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair SQL Server and outlook repair software products. For more information visit www.datanumen.com

Comments are closed.