VB add grandchild folder

I

isacp

I have been searching for a while but to no avail. I would like to
write code that adds a folder into a subfolder in the inbox. i.e. In my
in box I have a folder called "distribute" I want to add folders with
vb to the "distribute" folder.

(how can I add a child to a child?)
 
K

knowzero

I am very new to outlook.

is this something that should work?

Dim myOlApp As New Outlook.Application
Dim myOlFolders As Outlook.Folders

Public Sub fthsd()
Set myOlFolders =
myOlApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Folders("distribute")


myOlFolders.FolderAdd "tes"
End Sub
 
M

Michael Bauer [MVP - Outlook]

Am 18 Oct 2006 07:41:44 -0700 schrieb knowzero:

Yes, that works if the folder "distribute" exists already. (There´s just a
simple typo: It´s Folders.Add, not FolderAdd).

As long as you're in Outlook VBA, don´t try to create any new instance of
the Application object, instead use the instrinsic one:

Private myOlFolders As Outlook.Folders

Public Sub fthsd()
Set myOlFolders = Application.GetNamespace("MAPI") _
.GetDefaultFolder(olFolderInbox).Folders("distribute")
myOlFolders.Folders.Add "tes"
End Sub
 
Top