If you are keeping an Excel file which contains a list of contacts’ names and now you want to quickly import the corresponding business cards of outlook contacts into it, you can use the method introduced in this article.
Outlook allows users to export contact list. Yet, it can only export the information, unable to export the photos or business card images. Thus, if you have exported the contacts to an Excel worksheet and also wish to export the corresponding contacts’ business cards, you can learn the following methods. It’ll help you to achieve it in a jiffy.
Export the Business Cards of Contacts into an Excel Worksheet
- At the very outset, open the specific Excel workbook and switch to the source worksheet.
- Then, press “Alt + F11” key buttons to access Excel VBA editor.
- In the new window, enable “MS Outlook Object Library”. You can refer to the article – “How to Add an Object Library Reference in VBA”.
- Subsequently, click “Insert” > “Module”.
- Next, copy and paste the following VBA code into this new module.
Sub InsertBusinessCards() Dim strTempFolder As String Dim nRow As Integer Dim nLastRow As Integer Dim objSheetRange As Excel.Range Dim objRange As Excel.Range Dim objOutlookApp As Outlook.Application Dim objContacts As Outlook.Items Dim strContactName As String Dim objFoundContact As Outlook.ContactItem Dim strBusinessCard As String Dim objFileSystem As Object On Error Resume Next 'Create a temp folder strTempFolder = "E:\Business Cards\" MkDir (strTempFolder) Set objOutlookApp = CreateObject("Outlook.Application") Set objContacts = objOutlookApp.Session.GetDefaultFolder(olFolderContacts).Items 'Insert the business cards nLastRow = Cells(Rows.Count, "A").End(xlUp).Row For nRow = 2 To nLastRow Set objRange = Range("A" & nRow) If objRange.Value <> "" Then 'Find corresponding Outlook contacts based on name strContactName = objRange.Value Set objFoundContact = objContacts.Find("[FullName] = '" & strContactName & "'") strBusinessCard = strTempFolder & strContactName & ".jpg" objFoundContact.SaveBusinessCardImage (strBusinessCard) With ActiveSheet .Range("B" & nRow).ColumnWidth = 18 .Range("B" & nRow).RowHeight = 60 .Range("B" & nRow).Activate With .Pictures.Insert(strBusinessCard) With .ShapeRange .LockAspectRatio = msoTrue .Width = 100 .Height = 60 End With End With End With End If Next 'Delete the temp folder Set objFileSystem = CreateObject("Scripting.FileSystemObject") objFileSystem.DeleteFolder (strTempFolder) End Sub
- After that, you can run the macro right now. Just press “F5” key in the current macro.
- When the macro completes, you can return to the specific worksheet, which will look like the following screenshot:
Retrieve Outlook Data in the Event of Corruption
If you’re a regular user of Outlook, you may have ever encountered various issues in Outlook. Perhaps you have discovered that it is difficult and almost impossible to predict errors and damage. Hence, you had better keep an eye on the health of your Outlook file. Also, it is wise to make backup for Outlook data file on a regular basis. Moreover, keeping a more potent third party tool, like DataNumen Outlook Repair, is a matter of necessity. It can repair Outlook problems with ease,
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair mdf and outlook repair software products. For more information visit www.datanumen.com