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

makro for adressing more folders



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 15th 07, 08:41 AM posted to microsoft.public.outlook.program_vba
[email protected]\
external usenet poster
 
Posts: 2
Default makro for adressing more folders

Hi,



I have there a makro which make the same view settings from the chosen
"SOURCE FOLDER" for the chosen "TARGET FOLDER".

I want the adjastement in that way that if the "TARGET FOLDER" contains
some FOlDER more (UNDERFOlDER) like FOlDER "Mail" might contains

FOLDERS (JOB,

PRIVATE,

TO DO,

etc)



the view settings are equally changed for all this FOLDER's too. Have
somebody an idea how to adjust that makro to make it run for TARGET
FOLDER with more FOLDERS





Public Sub CopyView()

Dim TargetFolder As Outlook.MAPIFolder

Dim SourceFolder As Outlook.MAPIFolder

Set SourceFolder = Application.Session.PickFolder

If Not SourceFolder Is Nothing Then

Set TargetFolder = Application.Session.Folders(" ") ''' ???
'There are FOLDERS in the chosen FOLDER.


'TO DEFINE the chosen TargetFolder in the quotes

While Not TargetFolder Is Nothing

If TargetFolder.DefaultItemType = SourceFolder.DefaultItemType
Then



With TargetFolder.CurrentView

.XML = SourceFolder.CurrentView.XML

.Save

End With



Else

MsgBox "Source and target folder must be of the same type.",
vbInformation

End If

Set TargetFolder = Application.Session.PickFolder

Wend

End If

End Sub


Ads
  #2  
Old November 15th 07, 02:56 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default makro for adressing more folders

Each MAPIFolder object has a Folders collection that has any subfolders to
the parent folder. Once you have your parent folder, say TargetFolder you
can use its Folders collection to iterate each subfolder. Of course if those
subfolders have subfolders of their own you'd have to write a recursive
procedure to handle all of the subfolders and subfolders of subfolders. The
following example only shows digging down one level:

Dim lCount As Long
Dim oSub As Outlook.MAPIFolder

lCount = TargetFolder.Folders.Count
If lCount 0 Then
For Each oSub In TargetFolder.Folders
If oSub.DefaultItemType = SourceFolder.DefaultItemType Then
' whatever
End If
Next
End If

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


Leon Galushko ) wrote in message
...
Hi,



I have there a makro which make the same view settings from the chosen
"SOURCE FOLDER" for the chosen "TARGET FOLDER".

I want the adjastement in that way that if the "TARGET FOLDER" contains
some FOlDER more (UNDERFOlDER) like FOlDER "Mail" might contains

FOLDERS (JOB,

PRIVATE,

TO DO,

etc)



the view settings are equally changed for all this FOLDER's too. Have
somebody an idea how to adjust that makro to make it run for TARGET FOLDER
with more FOLDERS





Public Sub CopyView()

Dim TargetFolder As Outlook.MAPIFolder

Dim SourceFolder As Outlook.MAPIFolder

Set SourceFolder = Application.Session.PickFolder

If Not SourceFolder Is Nothing Then

Set TargetFolder = Application.Session.Folders(" ") ''' ???
'There are FOLDERS in the chosen FOLDER.


'TO DEFINE the chosen TargetFolder in the quotes

While Not TargetFolder Is Nothing

If TargetFolder.DefaultItemType = SourceFolder.DefaultItemType
Then



With TargetFolder.CurrentView

.XML = SourceFolder.CurrentView.XML

.Save

End With



Else

MsgBox "Source and target folder must be of the same type.",
vbInformation

End If

Set TargetFolder = Application.Session.PickFolder

Wend

End If

End Sub

  #3  
Old November 18th 07, 06:53 PM posted to microsoft.public.outlook.program_vba
[email protected]\
external usenet poster
 
Posts: 2
Default makro for adressing more folders



Hi Ken,



Thank your for your support!

I could adjust your example (digging down MAPIFolder’s level) with my
makro and that does work.

Leon



_____

Von: Ken Slovak - [MVP - Outlook] ]
Bereitgestellt: Donnerstag, 15. November 2007 15:57
Bereitgestellt in: microsoft.public.outlook.program_vba
Unterhaltung: makro for adressing more folders
Betreff: makro for adressing more folders


Each MAPIFolder object has a Folders collection that has any subfolders
to the parent folder. Once you have your parent folder, say TargetFolder
you can use its Folders collection to iterate each subfolder. Of course
if those subfolders have subfolders of their own you'd have to write a
recursive procedure to handle all of the subfolders and subfolders of
subfolders. The following example only shows digging down one level:



Dim lCount As Long

Dim oSub As Outlook.MAPIFolder



lCount = TargetFolder.Folders.Count

If lCount 0 Then

For Each oSub In TargetFolder.Folders

If oSub.DefaultItemType = SourceFolder.DefaultItemType Then

' whatever

End If

Next

End If


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





Leon Galushko ) wrote in message
...

Hi,



I have there a makro which make the same view settings from the chosen
“SOURCE FOLDER” for the chosen “TARGET FOLDER”.

I want the adjastement in that way that if the “TARGET FOLDER” contains
some FOlDER more (UNDERFOlDER) like FOlDER “Mail” might contains

FOLDERS (JOB,

PRIVATE,

TO DO,

etc)



the view settings are equally changed for all this FOLDER’s too. Have
somebody an idea how to adjust that makro to make it run for TARGET
FOLDER with more FOLDERS





Public Sub CopyView()

Dim TargetFolder As Outlook.MAPIFolder

Dim SourceFolder As Outlook.MAPIFolder

Set SourceFolder = Application.Session.PickFolder

If Not SourceFolder Is Nothing Then

Set TargetFolder = Application.Session.Folders(" ") ‘’’ ???
'There are FOLDERS in the chosen FOLDER.


'TO DEFINE the chosen TargetFolder in the quotes

While Not TargetFolder Is Nothing

If TargetFolder.DefaultItemType = SourceFolder.DefaultItemType
Then



With TargetFolder.CurrentView

.XML = SourceFolder.CurrentView.XML

.Save

End With



Else

MsgBox "Source and target folder must be of the same type.",
vbInformation

End If

Set TargetFolder = Application.Session.PickFolder

Wend

End If

End Sub


 




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
Makro with access to Sender.name jens m. guessregen Outlook and VBA 1 January 15th 07 12:46 PM
OL2k3 Automatically Adding Public Folders to 'Favorite Folders' list in Mail Ben Outlook - General Queries 0 October 4th 06 04:19 PM
Is there a way to display Public Folders in the All Mail Folders view? Outlook2003 Cappy Outlook - General Queries 1 July 20th 06 02:20 AM
Is there a way to display Public Folders in the All Mail Folders view? Outlook2003 Cappy Outlook - Installation 1 July 20th 06 02:20 AM
Hide/Delete Deleted Items & Search Folders Folders in Outlook 2003 jpspringall Outlook and VBA 1 April 24th 06 02:51 PM


All times are GMT +1. The time now is 11:13 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.