
Originally Posted by
ItsMe
In my example, I am using the folder picker thing vs. the file picker. I believe the default folder is the initial view property. You would add it with the other assignments within the With block of code.
Code:
.Title = "Locate an export to location"
.InitialView = \\ServerName\FolderName
.ButtonName = "Choose"
This code does not work for me. How can I fix this? (I changed the servername to the server I use).
I am now using the following code:
Code:
Private Sub ButtonPDF_Click()
Dim strPath As String
Dim strFileName As String
Dim ReportName As String
Dim strBeginPath As String
ReportName = Me.Name
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Locate an export to location"
.InitialView = msoFileDialogViewThumbnail
.ButtonName = "Choose"
If .Show = 0 Then
'TODO create some error handle stuff here
Exit Sub
End If
strPath = Trim(.SelectedItems(1))
End With
strFileName = [pdfName]
If Dir(strPath & "\" & strFileName & ".pdf", vbDirectory) <> "" Then
Dim LResponse As Integer
LResponse = MsgBox("File already exists, do you want to overwrite the file?", vbYesNo, "Warning")
If LResponse = vbYes Then
DoCmd.OutputTo acOutputReport, ReportName, acFormatPDF, strPath & "\" & strFileName & ".pdf"
Else
End If
Else
DoCmd.OutputTo acOutputReport, ReportName, acFormatPDF, strPath & "\" & strFileName & ".pdf"
End If
End Sub
This code gives the user the warning that the file already exists and asks to overwrite the file.