Error Checking in Excel
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: Importing a file

  1. #1
    Guest

    Default

    If I use the following code where do I put it? Can I attach it to a command button?

    Sub GetImportFileName()
    'Set up the file filters
    Filter = "Text Files (*.txt),*.txt," & _
    "Lotus Files (*.prn),*.prn," & _
    "Comma Separated Files (*.csv),*.csv," & _
    "ASCII Files (*.asc), *.asc," & _
    "All Files (*.*),*.*"

    'Display *.* default
    FilterIndex = 5

    'set dialog box caption
    Title = "Select a File to import"

    'get filename
    FileName = Application.GetOpenFilename(Filter, _ FilterIndex, Title)

    'Exit on cancel
    If FileName = Fales Then
    MsgBox = "No file selected"
    Exit Sub
    End If
    'Open file
    Workbooks.Open FileName

    I'm trying to import a file and create a worksheet that I can pull data from.

    Thanks,

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Ontario, Canada
    Posts
    337
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    In design mode right click on the button and select "view code" Paste your code here.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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