+ Reply to Thread
Results 1 to 2 of 2

How to select a specific file type

  1. #1
    MervB
    Guest

    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. #2
    RB Smissaert
    Guest

    Re: 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" <[email protected]> wrote in message
    news:[email protected]...
    >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 to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1