date format outlook vba

Joined
May 3, 2010
Messages
1
Reaction score
0
I am trying to create a pst file on the C:\root directory named as the current date though using the code;

Sub CreatePST()
Dim myOlApp As New Outlook.Application
Dim myNameSpace As Outlook.NameSpace
Set myNameSpace = myOlApp.GetNamespace("MAPI")
myNameSpace.AddStore "c:\" & Date & ".pst"
End Sub

Outlook creates the pst in a subfolder of day of the month as the year instead of on the root drive. Does anyone know how to format the date so that the file is saved on the root directory ie. to save as dd-mm-yy etc instead of dd/mm/yy. (eg, instead of using /)?

Any help greatly appreciated.

thanks

James
 
Hi, I'm very new to VBA and even newer to this forum.. (i actually registered here cos i wanted to answer ur question o.O) You probably have the answer now, but i guess this could help sumone else with the same prob..

I think this can be a solution:
myNameSpace.AddStore "c:\" & Replace(Date, "/", "-") & ".pst"

This would simply replace all the "/" in the date string with "-" (or anything you want).

Not hardcore at all, and gives what you need :)
 
Back
Top