![]() |
open some pst files at once in outlook
Hello,
I need to open several pst file in my outlook to compare some relevant emails in them. I find that I can only open one pst file every time by using "Open Outlook Data File” button. So I need to open them one by one . Can I have a button to open several pst files at once in outlook ? Thank you. |
Hi, PamLnnle,
For that, you can write VBA codes to do that. Try below macro. First, put all the pst files which you need to open into a same folder. Then run this macro. Please note you need to change the folder path "E:\" into your real path in code "Call LoopFolders("E:\") " Sub BatchOpenMultiplePSTFiles() 'You can change the path as per your needs 'You can also specify a folder other than a drive 'For instance - Call LoopFolders("C:\Users\Test\My Documents\Outlook Files") Call LoopFolders("E:\") MsgBox "Open Successfully!", vbExclamation + vbOKOnly, "Open Outlook Data File" End Sub Sub LoopFolders(strPath As String) Dim objFileSystem As Object Dim objFolder As Object Dim objFile As Object Dim objPSTFile As Object Set objFileSystem = CreateObject("Scripting.FileSystemObject") Set objFolder = objFileSystem.GetFolder(strPath) For Each objFile In objFolder.Files 'Find the pst file by file extension strFileExtension = objFileSystem.GetExtensionName(objFile) If LCase(strFileExtension) = "pst" Then Set objPSTFile = objFile 'Open the PST file Outlook.Application.Session.AddStore (objPSTFile.Path) End If Next 'Process all folders and subfolders in the Local Drive E If objFolder.SubFolders.Count 0 Then For Each objSubFolder In objFolder.SubFolders 'Skip the system and hidden folders If ((objSubFolder.Attributes And 2) = 0) And ((objSubFolder.Attributes And 4) = 0) Then LoopFolders (objSubFolder.Path) End If Next End If End Sub And I also attach th link of the codes he https://www.datanumen.com/blogs/batc...files-outlook/ Hope it helps. |
All times are GMT +1. The time now is 11:19 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com