One of a set of tools we're offering as a way of saying thank you for being a part of the community.
Public Function GetDirectory() 'This script allows the user to select a directory, 'making it possible for results to be exported to that 'directory. On Error GoTo ErrorHandler Dim strFolderPath As String Dim fd As Office.FileDialog 'Create a FileDialog object as a Folder Picker dialog box. Set fd = Application.FileDialog(msoFileDialogFolderPicker) With fd .Title = "Identify the database(s) containing your source data" .ButtonName = "Select" .InitialView = msoFileDialogViewDetails .InitialFileName = "\\ShareServer\" If .Show = -1 Then strFolderPath = CStr(fd.SelectedItems.Item(1)) & "\" Else Debug.Print "User pressed Cancel" strFolderPath = "" End If End With GetDirectory = Trim(strFolderPath) ErrorHandlerExit: Exit Function ErrorHandler: MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description Resume ErrorHandlerExit End Function
Join the community of 500,000 technology professionals and ask your questions.