+ Reply to Thread
Results 1 to 4 of 4

Thread: VBA in Excel to create subfolder in Oultook

  1. #1
    Registered User
    Join Date
    10-15-2011
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    VBA in Excel to create subfolder in Oultook

    Hi All,

    New here and new to VBA programming. I'm hoping to get some assistance with the following:

    I have a subfolder in my Outlook inbox (Inbox -> Directs). I would like to create an Excel file that I can enter employees names into Column A. Once the names are entered I want to be able to run a Macro that will automatically create subfolders in the "Directs" folder. The subfolders should be titled the name of the employee. (Inbox -> Directs -> JohnDoe).

    I would like for the file to be dynamic, meaning if the entire list of employees change, I would like the entire list of subfolders to change to reflect that. Also, the excel file will have a heading to the column ("employees") or something to the sort. So the names of the employee will not start until row 2.

    I'm using Office 2010. I hope this is enough information. Thanks in advance for any help you can provide!

  2. #2
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: VBA in Excel to create subfolder in Oultook

    sub snb
      on error resume next
      sn=sheets(1).cells(1).currentregion
      with createobject("outlook.Application").GetnameSpace("MAPI").getdefaultfolder(6).folders("direct")
         for j=2 to ubound(sn)
          .folders.add sn(j,1)
         next
      end with
    End Sub
    Last edited by snb; 10-17-2011 at 10:40 AM.



  3. #3
    Registered User
    Join Date
    10-15-2011
    Location
    Ohio, USA
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: VBA in Excel to create subfolder in Oultook

    Hi Snb,

    Thanks for the code.

    When I open the editor, I am creating a new module off of sheet 1. Then pasting the code into the module. I am then assigning the Macro to a button. However, whenever I hit the button nothing happens. I have "employee" in A1 of my sheet and employee names from A2:A10.

    Any ideas?

    I'm sorry but again I am not very familiar with VBA so I am having a hard time troubleshooting.

  4. #4
    Forum Guru snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,151

    Re: VBA in Excel to create subfolder in Oultook

    See the attachment.

    Check the existence of subfolder 'direct' in the PostIN-folder
    Attached Files Attached Files



+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.2.0