Solved

GetSaveAsFilename & filefilter for Excel 2007/2010

Posted on 2013-02-02
4
3,416 Views
Last Modified: 2013-02-03
Regarding the code below. Instead of text files, how would you make the filefilter Excel? Both 2007/2010


TextFilename = Application.GetSaveAsFilename(InitialFileName:="New_Name", _
            filefilter:="Text Files (*.txt), *.txt", _
            Title:="Enter a name for the text file and choose a folder in which to save the text file.")

    If TextFilename <> False Then
    'Copy the worksheet containing text and number data to a new, temporary workbook.
   
        ThisWorkbook.ActiveSheet.Copy
   
        ActiveWorkbook.SaveAs Filename:=DoleFilename, FileFormat:=xlText, CreateBackup:=False
       
        ActiveWorkbook.Close SaveChanges:=False

Thanks
0
Comment
Question by:dgd1212
[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
  • 2
  • 2
4 Comments
 
LVL 14

Expert Comment

by:Faustulus
ID: 38847852
filefilter:="Excel workbooks (*.xls*), *.xls*"
0
 

Author Comment

by:dgd1212
ID: 38847885
Perfect. Thank you.
To expand xls to include xlsx, xlsm, would that be:
filefilter:="Excel workbooks (*.xls*), *.xls*,(*.xlsx*), *.xlsx*,(*.xlsm*), *.xlsm*"
0
 
LVL 14

Accepted Solution

by:
Faustulus earned 500 total points
ID: 38848067
Not quite.
The base is xls. The asterisk stands for any letter or nothing.
So, xls* would include xlsx and xlsm as well as xls.
If you wanted to expand the filter please watch out for the comma. You can't have more than one. The comma separates the description you see from the filter you set.
Hence,
filefilter:="Excel workbooks (*.xls*), *.xls*"
has the same effect as
filefilter:="Excel workbooks, *.xls*"
If you wanted to include templates you should define
filefilter:="Excel workbooks (*.xls*)(*.xlt*), *.xls* *.xlt*"
You can also use a construct like this:-
Filter = "Excel Files (*.xls),*.xls," & _
        "Text Files (*.txt),*.txt," & _
        "All Files (*.*),*.*"
0
 

Author Closing Comment

by:dgd1212
ID: 38848674
Thank you for the solution and clarification.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

630 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