Search code examples
vbaoutlook

How to Give 'PickFolder' dialogue a title


I'm writing some code in which the user will need to pick both a source folder and destination folder using:

Set SourceFolder = GetObject("", "Outlook.Application").GetNamespace("MAPI").PickFolder

Set TargetFolder = GetObject("", "Outlook.Application").GetNamespace("MAPI").PickFolder

Is there a way to give the folder selector dialogue a heading so that I don't have to use a message box or something to tell the user which folder they are picking each time?


Solution

  • Not in Outlook Object Model. You can either

    a. Create your own form with the required functionality
    b. If using Redemption (I am its author) is an option, it exposes the RDOSelectFolder object, which allows to set the dialog caption (besides other things):

    set Session = CreateObject("Redemption.RDOSession")
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    set SelectFoldersDialog = Session.GetSelectFoldersDialog
    SelectFoldersDialog.Caption = "Please select your favorite folder"
    if SelectFoldersDialog.Display Then
      set Folder = SelectFoldersDialog.SelectedFolder
      MsgBox "selected folder: " & Folder.Name
    End If