VBOffice

Create a Set of Subfolders

For a project based filing system you often have to create the same subfolders for every new project folder. You can create any number of subfolders at once with a macro.

Last modified: 2015/05/06 | Accessed: 31.492  | #145
◀ Previous sample Next sample ▶
Reporter Reporter
VBOffice Reporter is an easy to use tool for data analysis and reporting in Outlook. A single click, for instance, allows you to see the number of hours planned for meetings the next month.

This sample adds four subfolders to the current folder. Edit the list to add the folders you need. The first array argument holds the folder name in quotation marks, the second one holds the folder type.

If you don't see every new folder after running the macro, press CTRL+6 in order to display the folder list. You can start the macro, for instance, by pressing ALT+F8.


tip  How to add macros to Outlook
Public Sub CreateSubfolders()
  Dim CurrentFolder As Outlook.MAPIFolder
  Dim Subfolder As Outlook.MAPIFolder
  Dim List As New VBA.Collection
  Dim Folders As Outlook.Folders
  Dim Item As Variant
  
  List.Add Array("Messages", olFolderInbox)
  List.Add Array("Appointments", olFolderCalendar)
  List.Add Array("Team", olFolderContacts)
  List.Add Array("ToDo", olFolderTasks)
  
  Set CurrentFolder = Application.ActiveExplorer.CurrentFolder
  Set Folders = CurrentFolder.Folders
  For Each Item In List
    Folders.Add Item(0), Item(1)
  Next
End Sub
ReplyAll ReplyAll
ReplyAll alerts you before unintentionally replying all, or if you are a confidential BCC recipient of the e-mail.
email  Send a message