2

I was looking for any options on a browse for folder within Outlook VBA. Currently I have, from a previous search:

Dim save_to_folder As String

save_to_folder = InputBox("Search returned " & objRsts.Count & " messages._ 
Please input folder location")

olkMsg.SaveAs save_to_folder & "\" & strDateName & "  " & strFileName & ".msg"

Where strDateName and strFileName are modified subjects and dates of the emails.

My problem is that I would like a browse option along with manually typing to prevent typos. I'm very new to VBA and need to auto-save emails very often, please let me know what my options are.

tshepang
  • 12,111
  • 21
  • 91
  • 136
user2414983
  • 21
  • 1
  • 2
  • How often are you doing this? Outlook doesn't support the normal office `Application.FileDialog()` method for some reason, but you can create a work around, but this depends on the way you want this to work. – enderland May 23 '13 at 19:30

1 Answers1

0

You could set up your code so you choose between InputBox and BrowseForFolder.

You could set these up separately.

I suggest you could use BrowseForFolder exclusively.

Dim oShell As Object
Set oShell = CreateObject("Shell.Application")
Dim save_to_folder  As Object
Set save_to_folder  = _
  oShell.BrowseForFolder(0, "Please Select a Save Folder:", 1)
If save_to_folder  Is Nothing Then Exit Sub
' Note:  BrowseForFolder doesn't add a trailing slash

Sample code here Macro to move selected outlook emails

Community
  • 1
  • 1
niton
  • 8,771
  • 21
  • 32
  • 52