View Single Post
  #1  
Old December 16th 07, 05:54 PM posted to microsoft.public.outlook.program_vba
StargateFan
external usenet poster
 
Posts: 48
Default Way to add prompt to this macro?

Hi! I was given a fantastic script on this board some time back which
I use all the time. It sorts the folders in the main Personal
Folders. This is the script he

************************************************** **************
Private Sub Application_Startup()
ExpandAllFolders
End Sub

Private Sub ExpandAllFolders()
On Error Resume Next
Dim Ns As Outlook.NameSpace
Dim Folders As Outlook.Folders
Dim CurrF As Outlook.MAPIFolder
Dim F As Outlook.MAPIFolder
Dim ExpandDefaultStoreOnly As Boolean

ExpandDefaultStoreOnly = True

Set Ns = Application.GetNamespace("Mapi")
Set CurrF = Application.ActiveExplorer.CurrentFolder

If ExpandDefaultStoreOnly = True Then
Set F = Ns.GetDefaultFolder(olFolderInbox)
Set F = F.Parent
Set Folders = F.Folders
LoopFolders Folders, True

Else
LoopFolders Ns.Folders, True
End If

DoEvents
Set Application.ActiveExplorer.CurrentFolder = CurrF
End Sub
Private Sub LoopFolders(Folders As Outlook.Folders, _
ByVal bRecursive As Boolean _
)
Dim F As Outlook.MAPIFolder

For Each F In Folders
Set Application.ActiveExplorer.CurrentFolder = F
DoEvents

If bRecursive Then
If F.Folders.Count Then
LoopFolders F.Folders, bRecursive
End If
End If
Next
End Sub
************************************************** **************

The thing is that the process takes a bit of time, which is absolutely
no problem. But a lot of times, the folders don't need to be expanded
each and every time O2K is launched and/or I need to get in
immediately.

How can we add a prompt to run this macro rather than having it run
automatically when all macros are enabled, pls?

Thank you! D
Ads