Consulting

Results 1 to 3 of 3

Thread: Macro to Create Subfolders in Active Folder

  1. #1
    VBAX Newbie
    Joined
    Jul 2006
    Posts
    4
    Location

    Macro to Create Subfolders in Active Folder

    Hi. I'm new to this forum, and relatively inexperienced with VBA. After searching this forum & Google, I'm still unable to find a way to automate the creation of subfolders in Outlook. The code would look something like this:

    'Determine selected folder (I have no idea how this should actually be done). The folder format will be "Projects GC2000-GC2024"
    Set Activefolder = (need proper code)

    'Create 25 individual subfolders, one for each project
    StartNumber=val(mid(Activefolder,12,4)) 'In this example, 2000
    For x=1 to 25
    Subfolder="GCQ-" & (StartNumber+x-1) 'Should be GCQ-2000 in the first iteration, then GCQ-2001, all the way to GCQ-2024
    createfolder (subfolder) 'I don't know the proper code for this!!! This needs to create a subfolder under Activefolder
    Next x

    Thanks in advance for your help!

    jdj

  2. #2
    VBAX Tutor
    Joined
    May 2004
    Location
    Germany, Dresden
    Posts
    217
    Location
    I'd try to get the currently selected folder first, and then check whether it's the right one.
    To get the selected folder use:
    [VBA]Set Activefolder = ActiveExplorer.CurrentFolder[/VBA]

    To create subfolders, you first need a folder object (like the one you get using the statement above) and then say:
    [VBA]ActiveFolder.Folders.Add("NewFolder")[/VBA]

    Daniel

  3. #3
    VBAX Newbie
    Joined
    Jul 2006
    Posts
    4
    Location
    ActiveFolder.Folders.Add("NewFolder")
    Was exactly what I needed. Thanks!

    What's the protocol now that I have a solution to my question- am I supposed to do something that closes this out?

    Thanks,

    jdj

Posting Permissions

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