Kovenna,
Tried several things but for now, this one is the only one that more of less can find a folder based on a searchstring (partial even).
The pickfolder routine I was trying at first, doesn't give a possibility to define a folder to be highlighted by default.
Anyway, here the code that finds a subfolder based on a searchstring.
Sub Get_Sub_Folders()
'declare some variables to use
Dim myinbox As Folder, mynofolders As Long, myfoldername As String
Dim foldersfound As Long, storefolder As String
'set your inbox to myinbox
Set myinbox = Application.Session.GetDefaultFolder(olFolderInbox)
'set variable to zero
foldersfound = 0
'display number of subfolders of myinbox = your default inbox
MsgBox myinbox.Folders.Count
'give a searchstring, can be partial but needs to give unique folder
myfoldername = InputBox("Give name ...", "Get folder ...")
'loop through subfolders of inbox
For mynofolders = 1 To myinbox.Folders.Count
'compare given searchstring with foldername
'if string is found then it must be greater than zero
If InStr(1, myinbox.Folders(mynofolders).Name, myfoldername) > 0 Then
'add 1 to foldersfound = to know if only one folders was found
'with searchstring
foldersfound = foldersfound + 1
'display messagebox
MsgBox "Folder <<< " & myinbox.Folders(mynofolders).Name & _
" >>> located with search : " & myfoldername
'store the name of the folder you found in a variable
storefolder = myinbox.Folders(mynofolders).Name
Else
'if searchstring isn't found in the subfolder name, display mesage
MsgBox myfoldername & " <> " & myinbox.Folders(mynofolders).Name
End If
'loop through all the subfolders of inbox
Next mynofolders
'if only one folder was found with searchstring, you found the folder
If foldersfound = 1 Then
MsgBox "Save to " & storefolder
Else
'if more, you need to give another searchstring to find a unique folder
MsgBox "More folders found with searchstring : " & myfoldername
End If
End Sub
Charlize