Save Report

Evagrius

Registered User.
Local time
Today, 11:40
Joined
Jul 10, 2010
Messages
170
Hi All,

I have this code behind a cmd on a report. It works great. I would like to offer the user the option to choose a name for the pdf file and allow them to choose where to save the file. Can anyone perhaps provide some guidance on how I can begin to do this. I know I have to envoke the file dialog but not sure how to proceed from there. Thank you for any help!


Code:
DoCmd.OutputTo acOutputReport, "MyReprot", acFormatPDF, "MyPDF.pdf", True

I tried using the FileDialog for SaveAs kept getting an error.
 
Last edited:
Hi All,

I have this code behind a cmd on a report. It works great. I would like to offer the user the option to choose a name for the pdf file and allow them to choose where to save the file. Can anyone perhaps provide some guidance on how I can begin to do this. I know I have to envoke the file dialog but not sure how to proceed from there. Thank you for any help!


Code:
DoCmd.OutputTo acOutputReport, "MyReprot", acFormatPDF, "MyPDF.pdf", True
I tried using the FileDialog for SaveAs kept getting an error.

I don't have Access 07 yet, but I would imagine that you use the file dialog to assign a string of the requested filepath to a string variable (e.g. strPath). Then use this code:

Code:
DoCmd.OutputTo acOutputReport, "MyReprot", acFormatPDF, strPath,  True
 
Hi,

That is acutally what I am trying to do - see below. The error is at - .filters.clear and .Filters.add - Any ideas?

Code:
  Dim fDialog As Office.FileDialog

    Dim varSelection As Variant
    Dim strFileName As String

    Set fDialog = Application.FileDialog(msoFileDialogSaveAs)
    With fDialog
        .Title = "Select Destination File"
        .InitialFileName = CurrentProject.Path & "\test.pdf"
        
        .Filters.Clear
        .Filters.Add "PDF Files", "*.PDF"

        .Show
    End With
 
Hi SpentGeezer,

It is Error Number 438 - Object does not support this property or method. I am not sure what I am doing wrong??
 
Hi SpentGeezer,

It is Error Number 438 - Object does not support this property or method. I am not sure what I am doing wrong??

The object doesn't support .filter.

You have used msoFileDialogSaveAs which doesn't allow the filter. If you were selecting a file with msoFileDialogFilePicker THEN you can use .filter.
 
Hi SpentGeezer - it does work if I use msoFileDialogFilePicker but then I am not able to allow the user to select where they would like to save their PDF File . . . I can't do anything with the FilePicker?

I am certain their must be some solution to make this work?
 
You have to use this, The user may have to type in the file extension.. or you may be able to put it in your VBA..

Code:
  Dim fDialog As Office.FileDialog

    Dim varSelection As Variant
    Dim strFileName As String

    Set fDialog = Application.FileDialog(msoFileDialogSaveAs)
    With fDialog
        .Title = "Select Destination File"
        .InitialFileName = CurrentProject.Path & "\test.pdf"
        .Show
    End With
 

Users who are viewing this thread

Back
Top Bottom