A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

collapse a specific mail folder from a macro in Outlook 2007



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old February 2nd 09, 03:07 PM posted to microsoft.public.outlook.program_vba
udo
external usenet poster
 
Posts: 6
Default 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
Ads
  #2  
Old February 2nd 09, 04:30 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default collapse a specific mail folder from a macro in Outlook 2007

You can't control whether a store is expanded or not in the folder list or
navigation pane in general. No way to do what you want.

--
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


"udo" wrote in message
...
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


  #3  
Old February 3rd 09, 11:27 AM posted to microsoft.public.outlook.program_vba
udo
external usenet poster
 
Posts: 6
Default collapse a specific mail folder from a macro in Outlook 2007

Thanks, Ken.

As an alternative, can I have my macro open the archive folder in a
new view, rather than navigate to it in the current view?

On Feb 2, 5:30*pm, "Ken Slovak - [MVP - Outlook]"
wrote:
You can't control whether a store is expanded or not in the folder list or
navigation pane in general. No way to do what you want.

--
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

"udo" wrote in message

...



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- Hide quoted text -


- Show quoted text -


  #4  
Old February 3rd 09, 03:46 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default collapse a specific mail folder from a macro in Outlook 2007

Not quite sure what you mean.

If you want the archive PST shown in a new, different window then you'd add
an Explorer to the Explorers collection (Explorers.Add) and set the
CurrentFolder of the new Explorer to display a folder in your PST file.

If the want the current window (Explorer) to show that PST folder using a
different view you set the ActiveExplorer.View object to whatever named view
you want or you set the ActiveExplorer.View.XML to the explicit view XML you
want to use.

--
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


"udo" wrote in message
...
Thanks, Ken.

As an alternative, can I have my macro open the archive folder in a
new view, rather than navigate to it in the current view?

  #5  
Old February 4th 09, 01:26 PM posted to microsoft.public.outlook.program_vba
udo
external usenet poster
 
Posts: 6
Default collapse a specific mail folder from a macro in Outlook 2007

Thanks, Ken - I used Explorers.Add and that was just what I need.
I saw there's a parameter for setting which display to use, but I
couldn't get rid of the To-Do Bar - how do I do that?


On Feb 3, 4:46*pm, "Ken Slovak - [MVP - Outlook]"
wrote:
Not quite sure what you mean.

If you want the archive PST shown in a new, different window then you'd add
an Explorer to the Explorers collection (Explorers.Add) and set the
CurrentFolder of the new Explorer to display a folder in your PST file.

If the want the current window (Explorer) to show that PST folder using a
different view you set the ActiveExplorer.View object to whatever named view
you want or you set the ActiveExplorer.View.XML to the explicit view XML you
want to use.

--
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

"udo" wrote in message

...
Thanks, Ken.

As an alternative, can I have my macro open the archive folder in a
new view, rather than navigate to it in the current view?


  #6  
Old February 4th 09, 03:56 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default collapse a specific mail folder from a macro in Outlook 2007

No way to do that using code that I know of. The folder display mode options
will open it normally or with no Navigation Pane. Even the
olFolderDisplayFolderOnly setting doesn't do what you want.

--
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


"udo" wrote in message
...
Thanks, Ken - I used Explorers.Add and that was just what I need.
I saw there's a parameter for setting which display to use, but I
couldn't get rid of the To-Do Bar - how do I do that?


  #7  
Old February 5th 09, 09:26 AM posted to microsoft.public.outlook.program_vba
udo
external usenet poster
 
Posts: 6
Default collapse a specific mail folder from a macro in Outlook 2007

Well, thanks anyway - the solution's great for me as it is
I appreciate it

On Feb 4, 4:56*pm, "Ken Slovak - [MVP - Outlook]"
wrote:
No way to do that using code that I know of. The folder display mode options
will open it normally or with no Navigation Pane. Even the
olFolderDisplayFolderOnly setting doesn't do what you want.

--
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

"udo" wrote in message

...
Thanks, Ken - I used Explorers.Add and that was just what I need.
I saw there's a parameter for setting which display to use, but I
couldn't get rid of the To-Do Bar - how do I do that?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
collapse a specific mail folder from a macro in Outlook 2007 udo Outlook - General Queries 2 February 2nd 09 03:08 PM
Save mail in a specific folder thomas Outlook and VBA 4 July 13th 08 03:02 AM
Set specific right margin in Outlook 2007 e-mail Douglas O. Walker Outlook - General Queries 2 December 2nd 07 07:57 PM
Rules for moving outside mails to specific folder (Macro) Moshico Outlook and VBA 1 January 22nd 07 03:03 PM
How to direct mail to specific folder crapit Outlook - General Queries 2 May 16th 06 03:47 AM


All times are GMT +1. The time now is 08:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.