PDA

View Full Version : Macro to Create Subfolders in Active Folder



JDJinTX
07-21-2006, 09:01 PM
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

Steiner
07-24-2006, 06:47 AM
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:
Set Activefolder = ActiveExplorer.CurrentFolder

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

Daniel

JDJinTX
07-24-2006, 03:14 PM
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