the following code is attached to the button_click on a report. I want to save the report under a name selected by the user.
Dim fd As FileDialog Set fd = Application.FileDialog(msoFileDialogSaveAs) fd.Show
When run, the save as dialog box pops up, but it does not save the file. Am I missing a step?
612 3 3 gold badges 11 11 silver badges 24 24 bronze badges
asked Apr 7, 2016 at 12:12
Robert Kendall Robert Kendall
380 2 2 gold badges 13 13 silver badges 28 28 bronze badges
You are missing the step of receiving the file name, and exporting the report to pdf format.
Commented Apr 7, 2016 at 13:03
You should, next, Export the report to pdf. Replace the line fd.Show with:
If fd.Show then DoCmd.OutputTo acOutputReport, "ReportNameHere", "PDF Format (*.pdf)", fd.SelectedItems(1), True End IF
The last Parameter True is to open the pdf after exported. Please remove if not not needed.
NOTE: fd.SelectedItems(1) is the file the user selected.
This looks like what I needed. "report name here" refers to the name of the report in access, not the desired filename, correct?
Commented Apr 7, 2016 at 15:40 Yes, a String value of the report name. Commented Apr 7, 2016 at 15:52You should also dim a boolean called notCancel, set it equal to .Show, and then using an If statement, use .Execute, the following code shows this:
Sub SaveFile() Dim fd As FileDialog Dim notCancel As Boolean Set fd = Application.FileDialog(msoFileDialogSaveAs) With fd notCancel = .Show If notCancel Then .Execute End If End With End Sub
1,485 1 1 gold badge 12 12 silver badges 18 18 bronze badges
answered Apr 7, 2016 at 13:06
Steve McFife Steve McFife
9 4 4 bronze badges
To subscribe to this RSS feed, copy and paste this URL into your RSS reader.
Site design / logo © 2024 Stack Exchange Inc; user contributions licensed under CC BY-SA . rev 2024.9.11.15092