![]() |
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 |
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 |
All times are GMT +1. The time now is 12:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com