PDA

View Full Version : Put outlook folder name in code - short macro



mvdbiest
02-23-2012, 09:43 AM
Hello

I have created a macro asking the user to select a folder, and then run another macro;
Public Sub MyMacro()
Dim mytoplvl As Folders
Set mytoplvl = Outlook.GetNamespace("MAPI").PickFolder.Folders
FolderPurge mytoplvl
End Sub


Public Sub FolderPurge(mytoplvl As Folders)
...
...
...
However, I would like to have the possibility to run this macro for certain folders, e.g. "Mailbox - Our Group Mailbox\Subfolder 1" but I cannot get this working. I have already tried several things, tried to google it, but I could not get my macro working.
Could anyone please give me a hint on how I can do this?
Any help will be appreciated

Thanks!

Michiel

JP2112
02-23-2012, 02:19 PM
Not sure I understand. You just pick the folder you want to process when the PickFolder Method fires. Doesn't that let you choose that folder?

mvdbiest
02-24-2012, 03:48 AM
Well, I actually want to hard code folders in the VBA code, so it doesn't ask the user what folder needs to be done.
The reason why, is because of the fact it takes some time to run my Folderpurge macro, so I have made it possible for my macro to run during the night. Unforrtunately, I cannot select a folder during the night, so I want it in my code...
I read this somewhere:

Set myDestFolder = objSubfolder.Folders("archive")

but I cannot get this working :(
In my case, it should be something like "Mailbox - Our Group Mailbox\Subfolder 1" instead of "archive"...

mvdbiest
02-29-2012, 05:26 AM
Does anyone have any tips for me? I really seem to be stuck... :(
I tried this
Public Sub MyMacro()
Dim mytoplvl As Outlook.MAPIFolder
Dim ns As Outlook.NameSpace
Set ns = Application.GetNamespace("MAPI")
Set mytoplvl = ns.GetFolderFromID("\\Mailbox - Our Group Mailbox\Subfolder 1")
but this does not work.
I might have a solution if I could use the EntryID for this folder - but where on earth can I find a folder's EntryID?
Thanks

skatonni
03-30-2012, 04:07 AM
In the Immediate Pane

?ActiveExplorer.CurrentFolder.EntryID