When you’re composing a document in MS Word and wish to insert the information of specific Outlook contact, you can use the following method in this article. It will teach you how to directly insert the specific contact’s business card image, which will look more active than textual information.
In my previous article – “2 Methods to Insert Outlook Contact Info into a Word Document”, I have introduced 2 tips to extract and add specific Outlook contact’s information into a word document. However, both of them can only insert the contact’s information in the form of text. Perhaps you may wish to directly insert the contacts’ business card image into the word document, in that it will be much more active and attractive. Here we will expose a quick tip that is using VBA.
Insert the Business Card of a Specific Contact into Your Word Document
- In the first place, open your Microsoft Word application.
- Then press “Alt + F11” key buttons to access your Word VBA editor.
- Next in the popup “Microsoft Visual Basic for Applications” window, click the “Tools” in the toolbar.
- From its drop down list, select “Reference”.
- Subsequently, in the new dialog box, find and enable the “Microsoft Outlook Object Library” like the screenshot below:
- After that, open a new module and copy the following VBA codes into it.
Private Sub InsertContactBusinessCard() Dim objOutlookApp As Outlook.Application Dim objContacts As Outlook.Items Dim strContactName As String Dim objContact As Outlook.ContactItem Dim strBusinessCard As String Dim objFileSystem As Object Dim strTempFolderPath As String Dim nPrompt As Integer Set objOutlookApp = CreateObject("Outlook.Application") Set objContacts = objOutlookApp.Session.GetDefaultFolder(olFolderContacts).Items strContactName = InputBox("Enter the full name of the specific Outlook contact:") Set objContact = objContacts.Find("[FullName] = '" & strContactName & "'") 'Check if there is such a contact If Not (objContact Is Nothing) Then 'Save the business card picture to Temp folder strBusinessCard = objContact.Fullname & ".jpg" Set objFileSystem = CreateObject("Scripting.FileSystemObject") strTempFolderPath = objFileSystem.GetSpecialFolder(2).Path & "\" & strBusinessCard objContact.SaveBusinessCardImage (strTempFolderPath) 'Insert the business card image to the current document Selection.InlineShapes.AddPicture FileName:=strTempFolderPath, LinkToFile:=False, SaveWithDocument:=True 'Delete the temporary business card image objFileSystem.DeleteFile (strTempFolderPath) Else nPrompt = MsgBox("No such a contact exists in your Outlook!", vbExclamation + vbOKOnly, "Find Contact") End If End Sub
- Finally you can have a try.
- Click the “Run” icon the toolbar in the VBA editor window.
- In the new dialog box, input the full name of the specific Outlook contact, like the image below:
- Then press “OK”. If the contact indeed exists in your Outlook, its business card image will be inserted to the document at once.
- If there is no such a contact in your Outlook, you will get a prompt:
PST File Is Same Vulnerable as Word Document
Maybe you have ever suffered word document corruption before. Actually PST file in Outlook is the same prone to damage. Therefore, you have to back up your PST file on a regular basis. Also, it’s highly recommended to prepare a potent PST fix tool in vicinity, 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 fix mdf and outlook repair software products. For more information visit www.datanumen.com