View Single Post
  #4  
Old December 3rd 07, 10:14 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Determine the user mailbox for a specific folder

I'd do it more like this:

Do While (Not (targetFolder Is Nothing))
strPath = targetFolder.Parent & "\" & strPath
Set targetFolder = targetFolder.Parent
Loop

The final iteration will be in error, so you might want to clear the Err
object if you intend to do any If testing or use other code that might be
affected by the error state.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"dch3" wrote in message
...
So I could adapt the function below to get the name then? - Stoping when I
get to 'MAPI' as the parent.

Public Function getFullFolderPath()
'Build the full path to the folder using the .parent property of the
selected folder by moving upward until will get to the topmost level.

Set nms = Outlook.Application.GetNamespace("MAPI")
Set targetFolder = nms.PickFolder

strPath = targetFolder

While targetFolder.Parent "Outlook"
strPath = targetFolder.Parent & "\" & strPath
Set targetFolder = targetFolder.Parent
Wend

Set targetFolder = Nothing
Set nms = Nothing

getFullFolderPath = strPath

End Function


Ads