Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default .GetOpenFilename - Filter on File Name

Hi,

Is there a way to filter the "File Name" when I use the .GetOpenFilename
dialog?
I'd like it to open to a folder, and then filter on text files with
"Monthly_Table_*.txt"
(I know I can filter on the ".txt" files, but I'd like to filter on the file
names too)

Thanks in advance for any pointers.
Chris
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,420
Default .GetOpenFilename - Filter on File Name

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "*mystring*.xls"

If .Show = 1 Then

MsgBox .SelectedItems(1)
End If
End With


--
__________________________________
HTH

Bob

"Chris" wrote in message
...
Hi,

Is there a way to filter the "File Name" when I use the .GetOpenFilename
dialog?
I'd like it to open to a folder, and then filter on text files with
"Monthly_Table_*.txt"
(I know I can filter on the ".txt" files, but I'd like to filter on the
file
names too)

Thanks in advance for any pointers.
Chris



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default .GetOpenFilename - Filter on File Name

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "Monthly_Table_*.txt"
.Show
strFile = .SelectedItems(1)
End With

If this post helps click Yes
---------------
Jacob Skaria


"Chris" wrote:

Hi,

Is there a way to filter the "File Name" when I use the .GetOpenFilename
dialog?
I'd like it to open to a folder, and then filter on text files with
"Monthly_Table_*.txt"
(I know I can filter on the ".txt" files, but I'd like to filter on the file
names too)

Thanks in advance for any pointers.
Chris

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default .GetOpenFilename - Filter on File Name

Thanks very much Jacob, very useful and thanks for the promptness.

One further thing I discovered thats causing a wobbly, is the file is not a
text file; its a .dat file.

Therefore it doesn't show. I've tried all categories but nothing seemed to
work.

Any chance you might know how this is resolved?

If not, no problem, you've already given me a good solution that I can work
around with, so thanks again.


"Jacob Skaria" wrote:

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "Monthly_Table_*.txt"
.Show
strFile = .SelectedItems(1)
End With

If this post helps click Yes
---------------
Jacob Skaria


"Chris" wrote:

Hi,

Is there a way to filter the "File Name" when I use the .GetOpenFilename
dialog?
I'd like it to open to a folder, and then filter on text files with
"Monthly_Table_*.txt"
(I know I can filter on the ".txt" files, but I'd like to filter on the file
names too)

Thanks in advance for any pointers.
Chris

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default .GetOpenFilename - Filter on File Name

I've added just one line to Jacob's code (the .Filters line)... this adds a
".dat" item to the selection list; the 1 at the end makes it the first item
in the list. I also changed the default file name's extension to ".dat".

Dim strFile As String
With Application.FileDialog(msoFileDialogOpen)
.Filters.Add "Dat Files", "*.dat", 1
.AllowMultiSelect = False
.InitialFileName = "Monthly_Table_*.dat"
.Show
strFile = .SelectedItems(1)
End With

--
Rick (MVP - Excel)


"Chris" wrote in message
...
Thanks very much Jacob, very useful and thanks for the promptness.

One further thing I discovered thats causing a wobbly, is the file is not
a
text file; its a .dat file.

Therefore it doesn't show. I've tried all categories but nothing seemed
to
work.

Any chance you might know how this is resolved?

If not, no problem, you've already given me a good solution that I can
work
around with, so thanks again.


"Jacob Skaria" wrote:

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "Monthly_Table_*.txt"
.Show
strFile = .SelectedItems(1)
End With

If this post helps click Yes
---------------
Jacob Skaria


"Chris" wrote:

Hi,

Is there a way to filter the "File Name" when I use the
.GetOpenFilename
dialog?
I'd like it to open to a folder, and then filter on text files with
"Monthly_Table_*.txt"
(I know I can filter on the ".txt" files, but I'd like to filter on the
file
names too)

Thanks in advance for any pointers.
Chris




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default .GetOpenFilename - Filter on File Name

Thanks Rick for the follow up.

"Rick Rothstein" wrote:

I've added just one line to Jacob's code (the .Filters line)... this adds a
".dat" item to the selection list; the 1 at the end makes it the first item
in the list. I also changed the default file name's extension to ".dat".

Dim strFile As String
With Application.FileDialog(msoFileDialogOpen)
.Filters.Add "Dat Files", "*.dat", 1
.AllowMultiSelect = False
.InitialFileName = "Monthly_Table_*.dat"
.Show
strFile = .SelectedItems(1)
End With

--
Rick (MVP - Excel)


"Chris" wrote in message
...
Thanks very much Jacob, very useful and thanks for the promptness.

One further thing I discovered thats causing a wobbly, is the file is not
a
text file; its a .dat file.

Therefore it doesn't show. I've tried all categories but nothing seemed
to
work.

Any chance you might know how this is resolved?

If not, no problem, you've already given me a good solution that I can
work
around with, so thanks again.


"Jacob Skaria" wrote:

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.InitialFileName = "Monthly_Table_*.txt"
.Show
strFile = .SelectedItems(1)
End With

If this post helps click Yes
---------------
Jacob Skaria


"Chris" wrote:

Hi,

Is there a way to filter the "File Name" when I use the
.GetOpenFilename
dialog?
I'd like it to open to a folder, and then filter on text files with
"Monthly_Table_*.txt"
(I know I can filter on the ".txt" files, but I'd like to filter on the
file
names too)

Thanks in advance for any pointers.
Chris


.

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
GetOpenFileName to select a .URL file Gary''s Student Excel Programming 10 April 22nd 08 08:37 PM
working on a selected file via GetOpenFilename periro16[_7_] Excel Programming 0 September 21st 05 01:52 PM
Using FileDialog or GetOpenFileName To Allow File Creation WhyIsDoug Excel Programming 1 July 28th 05 05:14 PM
Select file after GetOpenFilename RB Smissaert Excel Programming 1 February 5th 05 04:15 PM
GetOpenFilename - How can you filter files starting with a letter... rede96[_2_] Excel Programming 10 April 22nd 04 01:04 PM


All times are GMT +1. The time now is 04:44 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"