I have a functional VBA script I found online. However I would like to add one more task to this macro, but I have never done anything like this. When a folder is created via this macro, I would like it to also create a folder of the same name within Outlook. The folder would be in a subfolder within my archive folder called "Projects". So for example, in Outlook based on how this sheet is completed there would be 2 folders created.
Archive > Projects > 34 - Template in Word
Archive > Projects > 38 - Training Manual
The above format is only to show the path of the new folders. The existing portion to create the Windows folders works perfectly.
* Please note, I looked for special code tags for my VBA script that I am sharing, but did not see them anywhere.
Option Explicit
Sub MakeFolders()
Dim Folder As Range
Dim FolderPath As String
FolderPath = Range("MakeFolderPath").Value
On Error Resume Next
For Each Folder In Range("MakeFolderNames[Folder Name]")
MkDir FolderPath & "" & Folder.Text
Next Folder
End Sub
You'll need something like this:
Option Explicit
Sub MakeFolders()
Dim Folder As Range
Dim FolderPath As String
FolderPath = Range("MakeFolderPath").Value
Dim OutlookApp As Object
Set OutlookApp = GetObject(, "Outlook.Application")
Dim ProjectsFolder As Object
Set ProjectsFolder = OutlookApp.GetNamespace("MAPI").Folders("your email address here").Folders("Archive").Folders("Projects")
On Error Resume Next
For Each Folder In Range("MakeFolderNames[Folder Name]")
MkDir FolderPath & "" & Folder.Text
ProjectsFolder.Folders.Add Folder.Text
Next Folder
End Sub
@Velouria,
That worked perfectly!!!! I can't tell you how many times I have had a need to create a Windows and corresponding Outlook Project folder. I will get a ton of use from that code. Thanks so very much!
You're welcome. 🙂