Adds a Personal Folders (.pst) file to the current profile.
expression.AddStore(Store)
expression Required. An expression that returns a NameSpace object.
Store Required Variant. The path of the .pst file to be added to the profile. If the .pst file does not exist, Microsoft Outlook creates it.
Use the RemoveStore method to remove a .pst that is already added to a profile.
This Microsoft Visual Basic/Visual Basic for Applications (VBA) example adds a new Personal Folders (.pst) file to the user’s profile.
Sub CreatePST()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Set myNameSpace = myOlApp.GetNamespace("MAPI")
myNameSpace.AddStore "c:\" & myNameSpace.CurrentUser & ".pst"
End Sub
If you use Microsoft Visual Basic Scripting Edition (VBScript) in an Outlook form, you do not create the Application object. This example shows how to perform the same task using VBScript.
Sub CommandButton1_Click()
Set myNS = Application.GetNamespace("MAPI")
myNS.AddStore "c:\" & myNS.CurrentUser & ".pst"
End Sub