Link to home
Start Free TrialLog in
Avatar of Vodkasoda
VodkasodaFlag for Ireland

asked on

I need to point to my Personal Folders File in Outlook 2003

Hi, I am a Mainframe Programmer, but by no means an experienced VBA user, so whilst I can code the logic and processing, I have trouble with the pointers and setting up of variables, hopefully somebody can help me with this ...

I have the following VBA code that I used in an Outlook 2000 macro to access a specific personal folder which was just a sub-folder within INBOX :

Set ns = GetNamespace("MAPI")
Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set SubFolder1 = Inbox.Folders("Gary")
Set SubFolder2 = SubFolder1.Folders("Kickabout")
Set SubFolder3 = SubFolder2.Folders("Attachments")

This means I end up with SubFolder3 as the pointer to the folder I want to access.
 
In Outlook 2003, my folders are no longer sub-folders of INBOX, but are within a Personal Folders File "TheHeaths", though the sub-folders Gary/Kickabout/Attachments are the same ...

How do I amend/replace this code to work in Outlook 2003 please, to point directly at the Personal Foldefs File folder that I want to access ?!?

Any help much appreciated ...
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Vodkasoda

ASKER

DlueDevilFan, with due respect, I can't believe that I have to write (copy/paste, but you know what I mean !) all of that VBA code just to point at a specific Folder, even it is within my Personal Folders File, rather than the main Outlook 2003 Folders !!!

Andy Pope at OzGrid has given me the following code, which points me to my Personal Folders File, though I am still trying to work out how to access the sub-folder itself !!!

Set olApp = CreateObject("Outlook.Application")
Set ns = olApp.GetNamespace("MAPI")
Set Inbox = ns.Folders("TheHeaths")
No, you don't have to use that code to get to one particular folder.  The advantage of that code is that it will open ANY folder without having to change the code of the program.  If you put that code in a module, then you can reference it from ANY bit of Outlook VBA code you use and not have to write a nested series of statements like

Set Inbox = ns.GetDefaultFolder(olFolderInbox)
Set SubFolder1 = Inbox.Folders("Gary")
Set SubFolder2 = SubFolder1.Folders("Kickabout")
Set SubFolder3 = SubFolder2.Folders("Attachments")

every time you want to open some folder.  Reusable code is the better appraoch.
Yes, point taken and I do agree, but I am writing this for a home project and I can't see that I'd need to do anything like this again ... however, having taken a closer look at what you've writtem, I've implemented it & it worked perfectly first time !!!

Cheers BlueDevilFan