setting public folder

L

Lance Hoffmeyer

Hey all,

Found some code that either selects the default
calendar or allow me to pick a folder

Set MyFolder=onNamespace.GetDefaultFolder(9).Items
'Set MyFolder = onNamespace.PickFolder.Items


I would like to change these options so that
MyFolder is set to this folder/calendar:

"Public Folders\All Public Folders\DDD\DDD Calendar"


How do I do this in VBA Outlook 2007?

Lance
 
L

Lance Hoffmeyer

Worked like a charm. Thanks.

Lance


Used

Set MyFolder = GetFolder("Public Folders\All
Public Folders\DDD\DDD Calendar").Items


Public Function GetFolder(strFolderPath As String)
As MAPIFolder
' strFolderPath needs to be something like
' "Public Folders\All Public
Folders\Company\Sales" or
' "Personal Folders\Inbox\My Folder"

Dim objApp As Outlook.Application
Dim objNS As Outlook.NameSpace
Dim colFolders As Outlook.Folders
Dim objFolder As Outlook.MAPIFolder
Dim arrFolders() As String
Dim I As Long
On Error Resume Next

strFolderPath = Replace(strFolderPath, "/", "\")
arrFolders() = Split(strFolderPath, "\")
Set objApp = Application
Set objNS = objApp.GetNamespace("MAPI")
Set objFolder = objNS.Folders.Item(arrFolders(0))
If Not objFolder Is Nothing Then
For I = 1 To UBound(arrFolders)
Set colFolders = objFolder.Folders
Set objFolder = Nothing
Set objFolder = colFolders.Item(arrFolders(I))
If objFolder Is Nothing Then
Exit For
End If
Next
End If

Set GetFolder = objFolder
Set colFolders = Nothing
Set objNS = Nothing
Set objApp = Nothing
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top