Consulting

Results 1 to 3 of 3

Thread: Create folder an subfolder

  1. #1

    Create folder an subfolder

    Hi there,

    I would like to know if there is a way to create folder with subfolder.

    I would like to have an input box for the name of the folder. If not possible just a harcoded name such as "Employee name"

    the sub folder are all the same
    • Contract Documents
    • Personnal Documents
    • Remuneration
    • Visa/Trip
    • Insurance


    And again if possible a choose folder box for the parent folder. If not possible straight into the inbox is fine.

    I'm using outlook 2013.

    Many thanks to all.

    Best regards,

    Sastoka

  2. #2
    The following will allow you to choose the target folder and name the sub folder

    Option Explicit 
     
    Sub CreateSubFolder() 
        Dim olNS As Outlook.NameSpace 
        Dim olFolder As Outlook.MAPIFolder 
        Dim strName As String 
        On Error Resume Next 
        Set olNS = GetNamespace("MAPI") 
        Set olFolder = olNS.PickFolder 
        strName = InputBox("Enter sub-folder name") 
        If strName = "" Then 
            MsgBox "No name entered!" 
            GoTo lbl_Exit 
        End If 
        olFolder.folders.Add strName 
    lbl_Exit: 
        Set olNS = Nothing 
        Set olFolder = Nothing 
        Exit Sub 
    End Sub 
    
    
    Formatting tags added by mark007
    Graham Mayor - MS MVP (Word)
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Hi,

    Thanks a lot.

    That not complete but with the start you gave I did this.

    Option Explicit 
    Sub CreateSubFolder() 
        Dim olNS As Outlook.NameSpace 
        Dim olFolder As Outlook.MAPIFolder 
        Dim strName As String 
        Dim Folders As Outlook.Folders 
         
         
        On Error Resume Next 
        Set olNS = GetNamespace("MAPI") 
        Set olFolder = olNS.PickFolder 
        strName = InputBox("Enter sub-folder name") 
        If strName = "" Then 
            MsgBox "No name entered!" 
            GoTo lbl_Exit 
        End If 
        olFolder.Folders.Add strName 
        Set Folders = olFolder.Folders.Item(strName).Folders 
        Folders.Add "Doc Contrat", olFolderInbox 
        Folders.Add "Doc Personel", olFolderInbox 
        Folders.Add "Remuneration", olFolderInbox 
        Folders.Add "Visa/Trip", olFolderInbox 
        Folders.Add "Assurance", olFolderInbox 
         
    lbl_Exit: 
        Set olNS = Nothing 
        Set olFolder = Nothing 
        Exit Sub 
    End Sub 
    
    
    Formatting tags added by mark007
    And this does everything I want.

    Many thanks.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •