mvidas
asked on
VBA: Open and close a .pst file
Hi Everyone,
Can someone tell me, or point to somewhere that tells, how to open a .pst file as a personal folder via VBA? I'm assuming once I have that code I can figure out how to close it, I just cant figure it out and after a quick google search I couldnt find anything either.
If it helps, this is what I'm trying to accomplish via VBA code:
-Open "V:\personal\expo.pst"
-Move selected messages to that .pst file
-Close expo.pst
I'm pretty sure I can get steps 2 and 3 once I know how to open and reference the pst file/personal folder, just need the nudge in the right direction to open it.
EDIT: I'm using outlook 2000, if that helps.
Thanks!
Matt
Can someone tell me, or point to somewhere that tells, how to open a .pst file as a personal folder via VBA? I'm assuming once I have that code I can figure out how to close it, I just cant figure it out and after a quick google search I couldnt find anything either.
If it helps, this is what I'm trying to accomplish via VBA code:
-Open "V:\personal\expo.pst"
-Move selected messages to that .pst file
-Close expo.pst
I'm pretty sure I can get steps 2 and 3 once I know how to open and reference the pst file/personal folder, just need the nudge in the right direction to open it.
EDIT: I'm using outlook 2000, if that helps.
Thanks!
Matt
<-Move selected messages to that .pst file> & <Close expo.pst>
Look at the Outlook command line switches in the Outlook Help File. That should get you pointed in the right direction.
Andre...
Look at the Outlook command line switches in the Outlook Help File. That should get you pointed in the right direction.
Andre...
ASKER
Hi Andre,
I will look at the help file as I've never looked into using the command line with outlook before, but I think you may have missed my point. I'm looking for vba code to be run from within outlook, the above steps are just part of a much larger procedure. I could open the .pst file as stated above, but would that only be for the newly created instance of outlook, or would it also carry over to the existing instance?
I just tried running
outlook.exe V:\personal\expo.pst
And I got an error in outlook saying "Error performing inpage operation". It didn't open a new instance though, which is good, I'm just wondering if I got the syntax wrong (the file path/name is correct--I just re-verified).
Matt
I will look at the help file as I've never looked into using the command line with outlook before, but I think you may have missed my point. I'm looking for vba code to be run from within outlook, the above steps are just part of a much larger procedure. I could open the .pst file as stated above, but would that only be for the newly created instance of outlook, or would it also carry over to the existing instance?
I just tried running
outlook.exe V:\personal\expo.pst
And I got an error in outlook saying "Error performing inpage operation". It didn't open a new instance though, which is good, I'm just wondering if I got the syntax wrong (the file path/name is correct--I just re-verified).
Matt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Cool! Thanks BlueDevilFan, I learned something new too. As you can see, I am no coder.
Andre...
Andre...
You're welcome, Andre.
ASKER
Thanks, David!
I was able to accomplish my goal by using:
Dim olFold As Variant, iMsg As Variant
With Application.GetNamespace(" MAPI")
.AddStore "v:\personal\expo.pst"
Set olFold = .Folders("Personal Folders").Folders("export" ) 'or .Folders.GetLast
For Each iMsg In Application.ActiveExplorer .Selection
If TypeName(iMsg) = "MailItem" Then
iMsg.Move olFold
End If
Next
.RemoveStore olFold
End With
Unfortunately it did not work with my overall project (long story), but I'll still use part of it, plus I learned more about outlook vba.
Thanks again!
Matt
I was able to accomplish my goal by using:
Dim olFold As Variant, iMsg As Variant
With Application.GetNamespace("
.AddStore "v:\personal\expo.pst"
Set olFold = .Folders("Personal Folders").Folders("export"
For Each iMsg In Application.ActiveExplorer
If TypeName(iMsg) = "MailItem" Then
iMsg.Move olFold
End If
Next
.RemoveStore olFold
End With
Unfortunately it did not work with my overall project (long story), but I'll still use part of it, plus I learned more about outlook vba.
Thanks again!
Matt
You're welcome, Matt! Glad I could help out.
Thank you! This looks like it will do what I need also! I have a "offllosd" drive, I jiust need sometimes!
Andre...