• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1080
  • Last Modified:


I am trying to set filters for a FileSaveAs dialog using the following 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.Add "PDF Files", "*.PDF"

    End With

I get an error on the .Flters.Clear line, as well as the Filters.Add line. Everything works fine without those lines of code, but of course I don't get my desired filter. What am I missing?
1 Solution
Dave BrettVice President - Business EvaluationCommented:
VBA help says that you can't use Clear or Add with SaveAs   ... which isn't very helpful

So you need a workaround. I'm a Excel guy so there you would use GetSaveAsFilename. Not relevant I believe in Access, so a Access workaround would appear to be something like this



Jeffrey CoachmanMIS LiasonCommented:
<No points wanted>

A benefit of using brett's link is that it will work in versions of Access where you could not use the code you posted.
TechMommyAuthor Commented:
I was hoping that there was a better/simpler solution, but apparently there isn't. This is certainly an excellent workaround for the problem.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now