Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to reset the defined filters of the msoFileDialogFilePicker

Status
Not open for further replies.

wmbb

Technical User
Jul 17, 2005
320
NL
I'm using the code below inside a WORD macro.
When I try to run another macro opening another filetype the selection is restricted to the xls-files defined in the previous macro
How do I reset the filters of the msoFileDialogFilePicker at the end of the macro ?

Code:
Dim fd As FileDialog

' select excel-file
Set fd = Application.FileDialog(msoFileDialogFilePicker)
    fd.Title = "Selecting Excel Result File"
    fd.InitialFileName = ExcelResultDir
    fd.InitialView = msoFileDialogViewList
    fd.Filters.Clear
    fd.Filters.Add "Excel-files", "*.xls*"
    fd.FilterIndex = 1
    fd.ButtonName = "Choose &This file"
    If fd.Show <> -1 Then
        MsgBox "Macro stopped without selecting a Excel Result File"
        Exit Sub
    End If
 
You can just add a
Code:
fd.Filters.Clear
right before your Exit Sub and before your End Sub.

"Knowledge is power. Information is liberating. Education is the premise of progress, in every society, in every family." (Kofi Annan)
Oppose SOPA, PIPA, ACTA; measures to curb freedom of information under whatever name whatsoever.
 
Thanks, I'll try that.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top