If you frequently forget filling in specific important information when you save a contact in your Outlook, you can utilize the method introduced in this article. It can help you make some fields mandatory when filling in a contact.
When you create and save a contact in your Outlook, sometimes, you may forget filling in some vitally important information, such as company, job title, business telephone number or business address or birthday, etc. If such cases frequently occur, you must hope that Outlook can warn you at that time. However, Outlook doesn’t offer such a feature. Therefore, you need to make some extra efforts. Here we’ll teach you how to use Outlook VBA to achieve it. Read on to get the detailed steps and codes.
Make Some Fields Mandatory When Filling in an Outlook Contact
- In the first place, start your Outlook application.
- Then press “Alt + F11” key buttons.
- Next in the subsequent “Microsoft Visual Basic for Applications” window, you should open the “ThisOutlookSession” project window.
- Subsequently, you need to copy and paste the following codes into it.
Public WithEvents objInspectors As Outlook.Inspectors Public WithEvents objContact As Outlook.ContactItem Private Sub Application_Startup() Set objInspectors = Outlook.Application.Inspectors End Sub Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector) Set objContact = Inspector.CurrentItem End Sub 'Here we take the business information as an example 'You can change the details as per your own case Private Sub objContact_Write(Cancel As Boolean) Dim strJobTitle As String Dim strBusinessAddress As String Dim strBusinessPhone As String Dim nWarning As Integer If objContact.CompanyName <> "" Then If objContact.JobTitle = "" Then Cancel = True strMsg = "Now that you've filled in the Company info, " & "why not fill in Job Title too?" nWarning = MsgBox(strMsg, vbExclamation, "Missing Job Title") strJobTitle = InputBox("Input the contact job title here:") objContact.JobTitle = strJobTitle End If If objContact.BusinessAddress = "" Then Cancel = True strMsg = "Now that you've filled in the Company info, " & "why not fill in business address too?" nWarning = MsgBox(strMsg, vbExclamation, "Missing Business Address") strBusinessAddress = InputBox("Input the contact business address here:") objContact.BusinessAddress = strBusinessAddress End If If objContact.BusinessTelephoneNumber = "" Then Cancel = True strMsg = "Now that you've filled in the Company info, " & "why not fill in business telephone number too?" nWarning = MsgBox(strMsg, vbExclamation, "Missing Business Telephone Number") strBusinessPhone = InputBox("Input the contact business telephone number here:") objContact.BusinessTelephoneNumber = strBusinessPhone End If objContact.Close olSave End If End Sub
- After that, you have to sign this code as usual.
- Later change Outlook macro settings to permit the digitally signed macros.
- Finally restart your Outlook to activate the new macro.
- Now you can have a try. If you forget filling in the specific information when you hit “Save & Close” button, you’ll get a warning like the screenshot below:
- After that, an input box will pop up. You can fill in the missing information there.
Don’t Panic in Case of Outlook Troubles
If you have utilized Outlook for decades, it is possible that you have met various issues in Outlook. In general, for the small troubles, inbox repair tool, Scanpst.exe, can make effects. However, if what you are encountering is the damaged Outlook PST file, you have to resort to a more powerful tool, such as DataNumen Outlook Repair.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including mdf repair and outlook repair software products. For more information visit www.datanumen.com