Results 1 to 5 of 5
  1. #1
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    111

    Use FileDialog to get file with txt extension

    I can use the following code to search all files and return the value of the one I selected but do not know how to limit the files initially seen to just files with a txt extension. In effect, I only want to see files with txt extensions when searching for a file. Ideas?

    Code:
    Private Sub cmdGetTextFile_Click()
    Dim f As Object
    
    Set f = Application.FileDialog(3)
    
    f.AllowMultiSelect = True
    
    If f.Show Then
        For i = 1 To f.SelectedItems.Count
            varTextFileName = (f.SelectedItems(i))
            Me.TextfileLocation.Value = varTextFileName
            MsgBox "Text Location = " + Me.TextfileLocation.Value
        Next
    End If
        
    End Sub
    Access 2010

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    111
    Well now that looks overly complex. I was hoping to just add a line or two. Too much of a novice to make sense of all that. But thanks.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    Another reference https://msdn.microsoft.com/en-us/lib...ffice.11).aspx

    You need lines that clear and set the dialog filter.

    In your code, would be like:
    f.Filters.Clear
    f.Filters.Add = "Text Files", "*.TXT", "*.CSV"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    newbieX is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Posts
    111
    Much better reference. Finally got it to work. Thank you.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 02-09-2015, 03:24 PM
  2. Need to import .txt file using the extension only.
    By PJ Crittenden in forum Macros
    Replies: 3
    Last Post: 06-24-2014, 07:10 PM
  3. Replies: 1
    Last Post: 03-18-2014, 05:16 PM
  4. how to display the extension file access 2007
    By tintincute in forum Access
    Replies: 4
    Last Post: 08-04-2010, 10:09 AM
  5. access file extension help
    By supertech33 in forum Access
    Replies: 2
    Last Post: 02-17-2010, 03:31 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums