Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default How to select a specific file type

I have the following button code - how can I modify it so only a single .cvs
file can be chosen?

Private Sub btnETran_Click()
Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Show

' Display paths of each file selected
For lngCount = 1
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub

Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default How to select a specific file type

Sub btnETran_Click()
Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.Filters.Add "Text files", "*.txt; *.ini; *.bat", 1
.AllowMultiSelect = False
.Show

' Display paths of each file selected
For lngCount = 1 To 1
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub

To find this out just use the Object browser.
If you look in the list on the left you will see the FileDialog class with
on the right all the members.
One of them is Filters.
Right-click Filters and look in the help.


RBS




"MervB" wrote in message
...
I have the following button code - how can I modify it so only a single
.cvs
file can be chosen?

Private Sub btnETran_Click()
Dim lngCount As Long

' Open the file dialog
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Show

' Display paths of each file selected
For lngCount = 1
MsgBox .SelectedItems(lngCount)
Next lngCount

End With

End Sub

Thanks


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
select file from which to extract specific data Tel Excel Discussion (Misc queries) 3 July 16th 09 06:04 PM
I cannot select any options or type any data amber Excel Discussion (Misc queries) 1 April 17th 09 04:19 AM
can i type a number for a specific name to appear in the cell? FC Excel Discussion (Misc queries) 2 February 18th 07 07:17 PM
Select rows and sort based on type Sarah Excel Discussion (Misc queries) 0 October 11th 05 05:06 PM
Auto Select a file not knowing its specific name JeffFinnan Excel Programming 0 August 1st 03 12:57 PM


All times are GMT +1. The time now is 12:43 PM.

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"