Solved

Application.FileDialog(msoFileSaveAs)

Posted on 2011-02-16
3
1,042 Views
Last Modified: 2013-11-25
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.Clear
        .Filters.Add "PDF Files", "*.PDF"

        .Show
    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?
0
Comment
Question by:TechMommy
3 Comments
 
LVL 50

Accepted Solution

by:
Dave Brett earned 500 total points
ID: 34914520
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

http://www.mvps.org/access/api/api0001.htm

hth

Dave
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 34918187
<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.
0
 
LVL 11

Author Closing Comment

by:TechMommy
ID: 35072069
I was hoping that there was a better/simpler solution, but apparently there isn't. This is certainly an excellent workaround for the problem.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question