View Single Post
  #2  
Old January 16th 07, 04:49 AM posted to microsoft.public.outlook.program_vba
Dmitry Streblechenko
external usenet poster
 
Posts: 2,116
Default Why don't I need a MapiFolder object?

It is all up to you. The line

Debug.Print objExplorer.CurrentFolder.Name

can be split into

dim Folder As Outlook.MAPIFolder
set Folder = objExplorer.CurrentFolder
Debug.Print Folder.Name

That would be helpful if you are planning to access
objExplorer.CurrentFolder more than once. In that case it makes sense to
cache it in an explicitly declared variable rather than call
objExplorer.CurrentFolder multiple times.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"Carol G" wrote in message
news:2PWqh.675494$R63.605586@pd7urf1no...
I'm trying to wrap my head around the outlook objects. I'm sure this is a
stupid question but I'm having trouble grasping when I need to declare
objects and when I don't.
Why don't I need a MapiFolder object to view properties such as Name of
the
Current Folder below?
Confused....
Carol

Sub TestOfExpolorerObject()
Dim objApp As Outlook.Application
Dim objNms As Outlook.NameSpace
Dim objExplorer As Outlook.Explorer

Set objApp = CreateObject("Outlook.Application")
Set objNms = objApp.GetNamespace("Mapi")
Set objExplorer = objApp.ActiveExplorer

Debug.Print objExplorer.CurrentFolder.Name

Set objApp = Nothing
Set objNms = Nothing
Set objExplorer = Nothing
End Sub




Ads