Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
DRK DRK is offline
external usenet poster
 
Posts: 40
Default GetOpenFileName with F*.txt

In a perfect world, I want to have my list of available text files be only
those that start with the letter "F". It appears that Excel (97 in this case)
will honor a "*.TXT" but ignores the "F" if I specifiy it as "F*.TXT"

Does Excel(97) or any addition permit anything more than just "*.TXT"?
--
DRK
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default GetOpenFileName with F*.txt

As far as I know, there is no way to do this.


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"DRK" wrote in message
...
In a perfect world, I want to have my list of available text
files be only
those that start with the letter "F". It appears that Excel (97
in this case)
will honor a "*.TXT" but ignores the "F" if I specifiy it as
"F*.TXT"

Does Excel(97) or any addition permit anything more than just
"*.TXT"?
--
DRK



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 162
Default GetOpenFileName with F*.txt

It worked for me from the open file dialog in Excel XP.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default GetOpenFileName with F*.txt

Excel 2002 introduced an additional dialog - I don't know whether it
supports that filter structure or not, but GetOpenFileName is consistently
restrictive in its support through Excel 2003 to the best of my knowledge.

for xl2002 or later:

Sub Main()

'Declare a variable as a FileDialog object.
Dim fd As FileDialog

'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)

'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant

'Use a With...End With block to reference the FileDialog object.
With fd


.Filters.Add "Excel Files", "*.xls", 1

'Sets the initial file filter to number 2.
.FilterIndex = 1

' Next line does what you want
.InitialFileName = "C:\Data6\F*.xls"

'Use the Show method to display the File Picker dialog box and
return the user's action.
'The user pressed the action button.
If .Show = -1 Then

'Step through each string in the FileDialogSelectedItems
collection.
For Each vrtSelectedItem In .SelectedItems

'vrtSelectedItem is a String that contains the path of each
selected item.
'You can use any file I/O functions that you want to work
with this path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem

Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With

'Set the object variable to Nothing.
Set fd = Nothing

End Sub



--
Regards,
Tom Ogilvy

"DRK" wrote in message
...
In a perfect world, I want to have my list of available text files be only
those that start with the letter "F". It appears that Excel (97 in this

case)
will honor a "*.TXT" but ignores the "F" if I specifiy it as "F*.TXT"

Does Excel(97) or any addition permit anything more than just "*.TXT"?
--
DRK



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default GetOpenFileName with F*.txt

for clarification, after writing the first sentence, I went and test it
using the filedialog object and figured out how to do it (forgot to change
the sentence) - so in xl2002 and later you can use that, but the
getopenfilename function does not support it in any version.

--
Regards,
Tom Ogilvy

"Tom Ogilvy" wrote in message
...
Excel 2002 introduced an additional dialog - I don't know whether it
supports that filter structure or not, but GetOpenFileName is consistently
restrictive in its support through Excel 2003 to the best of my knowledge.

for xl2002 or later:

Sub Main()

'Declare a variable as a FileDialog object.
Dim fd As FileDialog

'Create a FileDialog object as a File Picker dialog box.
Set fd = Application.FileDialog(msoFileDialogFilePicker)

'Declare a variable to contain the path
'of each selected item. Even though the path is a String,
'the variable must be a Variant because For Each...Next
'routines only work with Variants and Objects.
Dim vrtSelectedItem As Variant

'Use a With...End With block to reference the FileDialog object.
With fd


.Filters.Add "Excel Files", "*.xls", 1

'Sets the initial file filter to number 2.
.FilterIndex = 1

' Next line does what you want
.InitialFileName = "C:\Data6\F*.xls"

'Use the Show method to display the File Picker dialog box and
return the user's action.
'The user pressed the action button.
If .Show = -1 Then

'Step through each string in the FileDialogSelectedItems
collection.
For Each vrtSelectedItem In .SelectedItems

'vrtSelectedItem is a String that contains the path of

each
selected item.
'You can use any file I/O functions that you want to work
with this path.
'This example simply displays the path in a message box.
MsgBox "The path is: " & vrtSelectedItem

Next vrtSelectedItem
'The user pressed Cancel.
Else
End If
End With

'Set the object variable to Nothing.
Set fd = Nothing

End Sub



--
Regards,
Tom Ogilvy

"DRK" wrote in message
...
In a perfect world, I want to have my list of available text files be

only
those that start with the letter "F". It appears that Excel (97 in this

case)
will honor a "*.TXT" but ignores the "F" if I specifiy it as "F*.TXT"

Does Excel(97) or any addition permit anything more than just "*.TXT"?
--
DRK







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default GetOpenFileName with F*.txt


To do this (Filter file lists) you need to use (for Pre xl2002 - nice
one Tom!)
the GetOpenFileName function from the comdlg32.dll

Have a look here for an explanation and code.

http://www.xcelfiles.com/comdlg.html


--
Ivan F Moala


------------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...fo&userid=1954
View this thread: http://www.excelforum.com/showthread...hreadid=376812

  #7   Report Post  
Posted to microsoft.public.excel.programming
DRK DRK is offline
external usenet poster
 
Posts: 40
Default GetOpenFileName with F*.txt

Thanks to you and everyone else who replied. Problem solved.
--
DRK


"Ivan F Moala" wrote:


To do this (Filter file lists) you need to use (for Pre xl2002 - nice
one Tom!)
the GetOpenFileName function from the comdlg32.dll

Have a look here for an explanation and code.

http://www.xcelfiles.com/comdlg.html


--
Ivan F Moala


------------------------------------------------------------------------
Ivan F Moala's Profile: http://www.excelforum.com/member.php...fo&userid=1954
View this thread: http://www.excelforum.com/showthread...hreadid=376812


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 help Leith Ross[_12_] Excel Programming 0 April 8th 05 10:14 PM
GetOpenFilename wtpcomplab Excel Programming 4 January 4th 05 06:36 PM
GetOpenFilename Jenny Excel Programming 2 October 22nd 04 01:38 PM
GetOpenFilename Wolfgang Excel Programming 1 February 6th 04 07:37 PM
getopenfilename inquirer Excel Programming 1 December 3rd 03 11:37 AM


All times are GMT +1. The time now is 09:30 AM.

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

About Us

"It's about Microsoft Excel"