makro for adressing more folders

L

leonid.galushko

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
 
K

Ken Slovak - [MVP - Outlook]

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




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
 
L

leonid.galushko

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] [mailto:[email protected]]
Bereitgestellt: Donnerstag, 15. November 2007 15:57
Bereitgestellt in: microsoft.public.outlook.program_vba
Unterhaltung: makro for adressing more folders
Betreff: Re: 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









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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top