Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / May 2008

Tip: Looking for answers? Try searching our database.

setting public folder

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lance Hoffmeyer - 28 May 2008 15:44 GMT
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
Sue Mosher [MVP-Outlook] - 28 May 2008 15:59 GMT
To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. For an example, see http://www.outlookcode.com/d/code/getfolder.htm.
Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> Hey all,
>
[quoted text clipped - 12 lines]
>
> Lance
Lance Hoffmeyer - 28 May 2008 16:29 GMT
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

> To get a non-default folder, you need to walk the folder hierarchy using the Folders collections or use a function that does that for you. For an example, see http://www.outlookcode.com/d/code/getfolder.htm.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.