Question : Output a report as PDF, prompt user for save location

This code is doing everything I want to except prompting the user for a save location.  It saves to the desktop by default.  I do not want to hard code a drive letter.  I appreciate the help.

Code Snippet:
1:
2:
3:
4:
5:
6:
7:
Dim strName As String
Dim strFile As String

strName = Forms![LookbackInput]![FinalBudID]
strFile = "" & strName

DoCmd.OutputTo acOutputReport, "LookbackReport", acFormatPDF, "" & strName & "-LookbackReport.pdf", True

Answer : Output a report as PDF, prompt user for save location

place this codes in a regular module

add to your references Microsoft Office 12 object library
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
Function SaveToFolder() As String
On Error GoTo ErrHandler
  
   Dim strFolderPath As String
   Dim fd As Office.FileDialog
  
   Set fd = Application.FileDialog(msoFileDialogFolderPicker)
  
   With fd
      .Title = "Browse for folder"
      .ButtonName = "Select"
      .InitialView = msoFileDialogViewDetails
      If .Show = -1 Then
         strFolderPath = CStr(fd.SelectedItems.Item(1)) & "\"
      Else
         strFolderPath = ""
      End If
   End With
  
   SaveToFolder = strFolderPath
    
ErrHandlerExit:
   Exit Function
  
ErrHandler:
   MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
   Resume ErrHandlerExit
  
End Function
Random Solutions  
 
programming4us programming4us