When you intend to export multiple contact groups as separate text files, you will surely feel it troublesome to export these groups one by one by standard “Save As”. Thus, in this article, we will teach you to use VBA to accomplish this task in one go.
It is admittedly easy to batch export several contact groups as a single text file. You can just select the groups and go to “File” > “Save As”. However, if you want to export multiple groups as separate text files, in general, by “Save As”, you need to save them one by one as text files. That is quite tedious and cumbersome. Thus, in the followings, we will teach you a much more effective way. Read on to get the detailed steps.
Batch Export Multiple Contact Groups to Text Files
- At the very beginning, start Outlook application.
- Then, trigger Outlook VBA editor via “Alt + F11” key buttons.
- Next, in the new window, put the following code into an unused module.
Sub ExportMultipleContactGroupsIntoWordDocuments() Dim objSelection As Outlook.Selection Dim objShell As Object Dim objWindowsFolder As Object Dim objItem As Object Dim objContactGroup As Outlook.DistListItem Dim strFilePath As String 'Get selected contact groups Set objSelection = Outlook.Application.ActiveExplorer.Selection If Not objSelection Is Nothing Then 'Select a Windows folder Set objShell = CreateObject("Shell.Application") Set objWindowsFolder = objShell.BrowseForFolder(0, "Select a folder to save the contact groups:", 0, "") If Not objWindowsFolder Is Nothing Then For Each objItem In objSelection If TypeOf objItem Is DistListItem Then Set objContactGroup = objItem 'Save the contact group as text strFilePath = objWindowsFolder.self.Path & "\" & objContactGroup.DLName & ".txt" objContactGroup.SaveAs strFilePath, olTXT End If Next 'Open the Windows folder Call Shell("explorer.exe " & objWindowsFolder.self.Path, vbNormalFocus) End If End If End Sub
- After that, exit the VBA editor.
- Later, follow the “Optional Steps” in “How to Run VBA Code in Your Outlook” to add this macro to Quick Access Toolbar or ribbon.
- Finally, try it.
- First off, select the contact groups that you want to export.
- Then, click the newly added macro button.
- Next, in the popup dialog box, select a Windows folder to save exported contact groups.
- Ultimately, click “OK” to ensure the Windows folder.
- At once, the Windows folder will be displayed, in which you can see the exported text files.
Repair Corrupted PST File
Have you ever encountered PST corruption in your Outlook? You must be panic if you come across it. Actually, as long as you take correct and effective solutions, it is still easy to retrieve the damaged PST data. For instance, you can take aid of an experienced PST repair tool, such as DataNumen Outlook Repair. It is able to help you restore PST data within minutes and with high recovery rate. In a nutshell, it is worthy of a try.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including sql repair and outlook repair software products. For more information visit www.datanumen.com