View Full Version : Solved: Dialog Box
counterrojo
12-05-2011, 08:04 PM
Hi,
I am trying to access a dialog box to allow users to select a location for files to be saved in. From what I can see Outlook does not have a dialog box object, but windows does. I have tried all sorts of code off of the internet and have had zero luck. I am using Outlook 2010 64bit. Does anyone have an Idea how I can do this?
Thank you,
Michael
JKwan
12-08-2011, 07:00 AM
Try this out:
Function BrowseForFolder() As String
Dim ShellApp As Object
Set ShellApp = CreateObject("Shell.Application"). _
BrowseForFolder(0, "Please choose a folder", 0, OpenAt)
On Error Resume Next
BrowseForFolder = ShellApp.self.Path
On Error GoTo 0
Select Case Mid(BrowseForFolder, 2, 1)
Case Is = ":"
If Left(BrowseForFolder, 1) = ":" Then
BrowseForFolder = ""
End If
Case Is = "\"
If Not Left(BrowseForFolder, 1) = "\" Then
BrowseForFolder = ""
End If
Case Else
BrowseForFolder = ""
End Select
ExitFunction:
Set ShellApp = Nothing
End Function
Sub GetDirectoryName()
Dim StrSavePath As String
StrSavePath = BrowseForFolder
If StrSavePath = "" Then GoTo ExitSub
If Not Right(StrSavePath, 1) = "\" Then
StrSavePath = StrSavePath & "\"
End If
MsgBox StrSavePath
ExitSub:
End Sub
counterrojo
12-08-2011, 09:52 AM
Thank you JKwan. That did the trick.
Have a great day,
Michael
counterrojo
12-15-2011, 02:33 PM
I have found a second solution to this problem. It works nice as well.
Public Sub TestFileDialog()
Dim otherObject As Excel.Application
Dim fdFolder As office.FileDialog
Set otherObject = New Excel.Application
otherObject.Visible = False
Set fdFolder = otherObject.Application.FileDialog(msoFileDialogFolderPicker)
fdFolder.Show
Debug.Print fdFolder.SelectedItems(1)
otherObject.Quit
Set otherObject = Nothing
End Sub
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.