collapse a specific mail folder from a macro in Outlook 2007

Hi,
My Outlook 2007 archives emails to a "archivel" folder tree structure
that is parallel to my mailbox folders.
I've written a macro that switches between a folder and its archive
(see below)
As a safety measure, I want the "archivel" folder collapsed altogether
when I switch back to the non-archive folder, so that I don't confuse
its folders with the normal ones - any Idea how I do this?

Thanx in advance.

----------------------------------

Sub SwitchBetweenCurrentFolderAndItsArchive()
Dim names As Collection
Set names = New Collection
Dim cf As Folder
Set cf = Application.ActiveExplorer.CurrentFolder
Set f = cf
Do While Not f Is Nothing And TypeOf f Is MAPIFolder
    names.Add (f.Name)
    Set f = f.Parent
Loop

Dim newf As Folder
If names(names.Count) <> "Archivel Folders" Then
Set newf = f.Folders("Archivel Folders")
MsgBox "Switching from a folder to its ARCHIVE"
Else
Set newf = f.GetDefaultFolder(olFolderInbox).Parent
MsgBox "Switching from an archive back to its FOLDER"
End If

' remove 'mailbox' item
names.Remove (names.Count)

While names.Count > 0
    'MsgBox names.Item(names.Count)
    Set newf = newf.Folders(names.Item(names.Count))
    names.Remove (names.Count)
Wend

Set Application.ActiveExplorer.CurrentFolder = newf
End Sub
0
uridor (3)
2/1/2009 2:54:23 PM
outlook 87535 articles. 11 followers. Follow

2 Replies
284 Views

Similar Articles

[PageSpeed] 13

"udo" <uridor@gmail.com> wrote in message 
news:7a47b1ca-47a5-4779-bb6f-d53c3497786d@q30g2000prq.googlegroups.com...

> My Outlook 2007 archives emails to a "archivel" folder tree structure
> that is parallel to my mailbox folders.
> I've written a macro that switches between a folder and its archive
> (see below)
> As a safety measure, I want the "archivel" folder collapsed altogether
> when I switch back to the non-archive folder, so that I don't confuse
> its folders with the normal ones - any Idea how I do this?

Programming questions belong in microsoft.public.outlook.program_vba
-- 
Brian Tillman [MVP-Outlook] 

0
tillman1952 (16052)
2/2/2009 1:32:43 PM
On Feb 2, 3:32=A0pm, "Brian Tillman [MVP - Outlook]"
<tillman1...@yahoo.com> wrote:
> "udo" <uri...@gmail.com> wrote in message
>
> news:7a47b1ca-47a5-4779-bb6f-d53c3497786d@q30g2000prq.googlegroups.com...
>
> > My Outlook 2007 archives emails to a "archivel" folder tree structure
> > that is parallel to my mailbox folders.
> > I've written a macro that switches between a folder and its archive
> > (see below)
> > As a safety measure, I want the "archivel" folder collapsed altogether
> > when I switch back to the non-archive folder, so that I don't confuse
> > its folders with the normal ones - any Idea how I do this?
>
> Programming questions belong in microsoft.public.outlook.program_vba
> --
> Brian Tillman [MVP-Outlook]

Thanks - I posted there now.
0
uridor (3)
2/2/2009 2:08:35 PM
Reply:

Similar Artilces: