Thread: [Solved] Optional File Browsing
View Single Post
 
Old 03-08-2011, 01:10 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Here's one way:
Code:
Dim strFile As String
strFile = "C:\Users\BK\Desktop\DATA.txt"
With Application.FileDialog(msoFileDialogFilePicker)
  .AllowMultiSelect = False
  .Show
  If .SelectedItems.Count = 1 Then
    strFile = .SelectedItems(1)
  Else
    MsgBox "No file selected", vbExclamation
    Exit Sub
  End If
End If
'IMPORT the file from desktop (DATA.txt)
    With ActiveSheet.QueryTables.Add(Connection:= _
        "TEXT;" & strFile, Destination:=Range("$A$1"))
     ...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote