Solved

GetSaveAsFilename & filefilter for Excel 2007/2010

Posted on 2013-02-02
4
3,264 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Excel can be a tricky bit of software to get your head around. Whilst you’ll be able to eventually get to grips with the basic understanding of how to get by, there are a few Excel tips that not everybody will even know about let alone know how to d…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

729 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