PDA

View Full Version : Solved: Accessing Multiple pst files simultaneously



MWE
02-08-2012, 03:31 PM
I am running ol2003 and WinXP. I have several ol profiles each with multiple pst files (one primary and several "data files"). I wish to process multiple contact lists (one from each of two pst files) within a VBA procedure. It is easy to work with the contacts file from the primary pst file; how to I access one of the other ones at the same time?

Thanks

JP2112
02-23-2012, 02:04 PM
Have you checked out the AddStore Method (http://msdn.microsoft.com/en-us/library/aa210225(v=office.11).aspx)?

MWE
02-24-2012, 06:13 PM
Have you checked out the AddStore Method (http://msdn.microsoft.com/en-us/library/aa210225%28v=office.11%29.aspx)?Thanks for the reply. I found a fairly simply way to do this. I sequence through all the pst files attached to the particular profile:
pst1:
Set objOL = Application ' intrinsic Application object in Outlook VBA
Set objNS = objOL.GetNamespace("MAPI")
For Each olPSTFolder1 In objNS.Folders
If olPSTFolder1.Name = "first pst I want" Then
For Each olConFolder1 In olPSTFolder1.Folders
If olConFolder1.Name = "Contacts" Then
GoTo pst2
End If
Next olConFolder1
End If
Next olPSTFolder1
pst2: At the end of the above code (I removed the testing code to ensure that I do not drop out of the loops with finding what I want), olConFolder1 is the first Contacts folder. I repeat the above process and find olConFolder2