Vadhimoo, the declaration of:
startFolder as Outlook.Folder
is for OL 2007. For earlier versions it's
startFolder as Outlook.Mapifolder
--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook
--
www.VBOffice.net --
Am Tue, 5 Dec 2006 00:39:37 -0800 schrieb Vadhimoo:
Dear Sue Mosher,
Good Morning , Thanks for your response.When i run the below code.
I got the Compile Error.
For this line: Sub ProcessFolder(startFolder As Outlook.Folder)
Error is: Used-defined type not defined.
I am using Microsoft Outlook 2003.Please assist me.Have a nice day.
Dear Michael Bauer,
We cant able to view the "Thread " Answer for the last three days.I sent a
mail to microsoft helpdesk at ". Today only we view
this thread.
Have a nice day.
Thanks and Regards,
Vadhimoo.
"Sue Mosher [MVP-Outlook]" wrote:
This Outlook VBA sample code (from my forthcoming Outlook 2007
programming book recurses the entire folder hierarchy to build a string
(mstrList) of all the folders along with the number of items in each one.
Dim mlngItemCount As Long
Dim mlngFolderCount As Long
Dim mstrList As String
Sub ListAllFolders()
Dim objOL As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.Folder
Dim objMsg As Outlook.MailItem
mlngItemCount = 0
mlngFolderCount = 0
mstrList = ""
Set objOL = Application
Set objNS = objOL.Session
For Each objFolder In objNS.Folders
Call ProcessFolder(objFolder)
mstrList = mstrList & vbCrLf
Next
Set objMsg = objOL.CreateItem(olMailItem)
mstrList = mstrList & vbCrLf & _
"Total folders in Outlook = " & _
Format(mlngFolderCount, "###,###") & _
vbCrLf & "Total items in Outlook = " & _
Format(mlngItemCount, "###,###")
objMsg.Body = mstrList
objMsg.Display
Set objOL = Nothing
Set objNS = Nothing
Set objFolder = Nothing
End Sub
Sub ProcessFolder(startFolder As Outlook.Folder)
Dim objFolder As Outlook.Folder
On Error Resume Next
mstrList = mstrList & vbCrLf & startFolder.FolderPath & _
vbTab & startFolder.Items.Count
mlngItemCount = mlngItemCount + startFolder.Items.Count
mlngFolderCount = mlngFolderCount + 1
For Each objFolder In startFolder.Folders
Call ProcessFolder(objFolder)
Next
Set objFolder = Nothing
End Sub
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Vadhimoo" wrote in message
news

Hi
We are having more than 2000 folders in our INBOX. We would like to
extract
all the folders name to excel. How can we extract all the folders
name..?
Thanks in advance for your reply.