Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Filter only shortcuts and xl files

"Charles Chickering" wrote in
message
.FilterIndex = 2


I'm not entirely sure that I would want to rely on the correct filter being
in position 2, especially since Filters can be added and deleted. Instead,
I'd probably modify the code I posted earlier to the following:

Dim FName
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
.Filters.Add "Excel File (*.xls)", "*.xls", .Filters.Count + 1
.FilterIndex = .Filters.Count

If Not .Show Then
.Filters.Delete .Filters.Count
Exit Sub
End If
.Filters.Delete .Filters.Count
FName = .SelectedItems(1)
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Charles Chickering" wrote in
message ...
Hi Steven, try this:
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
.FilterIndex = 2
If Not .Show Then Exit Sub
FName = .SelectedItems(1)
End With

--
Charles Chickering

"A good example is twice the value of good advice."


"Steven" wrote:

I have the following code:

Private Sub OpenMyDocuments()
On Error GoTo ErrMacro

Dim FName As String
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
If Not .Show Then Exit Sub
FName = .SelectedItems(1)
End With

If Len(FName) 0 Then
Set wb = Workbooks.Open(FName)
End If

Application.RecentFiles.Add Name:=FName

Windows("Notes.xls").Close (0)

ErrMacro:

End Sub

It shows - All Files (*.*) - in the Files of Type field. How do I make
it
default to - All Microsoft Office Excel Files - ?

Thank you for your help.

Steven



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Filter only shortcuts and xl files

I don't believe there is a way to reset the filters, but I must admit I've
never tried. They do get reset when you close the Excel application.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)

"Charles Chickering" wrote in
message ...
That's interesting, is there a way to reset filters after someone has
screwed
with them?
--
Charles Chickering

"A good example is twice the value of good advice."


"Chip Pearson" wrote:

"Charles Chickering" wrote
in
message
.FilterIndex = 2


I'm not entirely sure that I would want to rely on the correct filter
being
in position 2, especially since Filters can be added and deleted.
Instead,
I'd probably modify the code I posted earlier to the following:

Dim FName
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
.Filters.Add "Excel File (*.xls)", "*.xls", .Filters.Count + 1
.FilterIndex = .Filters.Count

If Not .Show Then
.Filters.Delete .Filters.Count
Exit Sub
End If
.Filters.Delete .Filters.Count
FName = .SelectedItems(1)
End With


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)


"Charles Chickering" wrote
in
message ...
Hi Steven, try this:
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
.FilterIndex = 2
If Not .Show Then Exit Sub
FName = .SelectedItems(1)
End With

--
Charles Chickering

"A good example is twice the value of good advice."


"Steven" wrote:

I have the following code:

Private Sub OpenMyDocuments()
On Error GoTo ErrMacro

Dim FName As String
With Application.FileDialog(msoFileDialogOpen)
.InitialFileName = "%UserProfile%\My Documents"
.AllowMultiSelect = False
If Not .Show Then Exit Sub
FName = .SelectedItems(1)
End With

If Len(FName) 0 Then
Set wb = Workbooks.Open(FName)
End If

Application.RecentFiles.Add Name:=FName

Windows("Notes.xls").Close (0)

ErrMacro:

End Sub

It shows - All Files (*.*) - in the Files of Type field. How do I
make
it
default to - All Microsoft Office Excel Files - ?

Thank you for your help.

Steven






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel files on USB -- taskbar shortcuts don't work Xr8y Excel Discussion (Misc queries) 0 January 16th 11 08:45 PM
How to remove listed shortcuts for deleted Excel files? Dave Excel Discussion (Misc queries) 1 August 11th 08 01:06 AM
all my shortcuts to excel files open up as a picture Gimbee Excel Discussion (Misc queries) 0 April 13th 08 12:39 AM
Filter only shortcuts and xl files Chip Pearson Excel Programming 0 January 5th 07 04:49 PM
shortcuts to excel files. nitm Excel Programming 11 February 14th 05 05:37 PM


All times are GMT +1. The time now is 10:47 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"