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
- To start with, launch your Outlook program.
- Then press “Alt + F11” key buttons to open Outlook VBA editor.
- Next click “Insert” and select “UserForm”.
- Then hit the “ComboBox” button and then drag and drop in the UserForm1 to insert a custom combo box.
- Next right click on the combo box and select “View Code”.
- 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
- Next double click on the “UserForm1”.
- After that, hit the “CommandButton” button in “Toolbox” and then drag and drop in the UserForm1 to insert a command button.
- Subsequently, click on the new button and change its caption to “OK” in the “Properties – CommandButton1”.
- Then, pitch on the “UserForm1” and change its caption to “Select Company”.
- 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
- After that, add the new macro to the Quick Access Toolbar of contact window.
- Later change your Outlook macro security level to low.
- 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”.
- 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.
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