Solved

Application.FileDialog(msoFileSaveAs)

Posted on 2011-02-16
3
1,022 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
Comment Utility
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
Comment Utility
<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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now