?
Solved

Application.FileDialog(msoFileSaveAs)

Posted on 2011-02-16
3
Medium Priority
?
1,052 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 50

Accepted Solution

by:
Dave Brett earned 2000 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
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…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…

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