+ Reply to Thread
Results 1 to 3 of 3

Open Multiple Files

  1. #1
    Registered User
    Join Date
    07-18-2007
    Posts
    10

    Select One file from multiple files

    I coded a macro that opens another workbook and then extracts information from it and finally closes it without saving. It worked smooth.

    Now my requirements have changed. I have instead few workbooks to choose from to extract the data based on few criteria. I was wondering if a macro can be coded that would allow me to do so. Basically when the macro is executed, it should throw a "open file" window allowing me to choose the file of my choice. I then pick the file and the macro does the rest.

    Thanks for any help.
    DD
    Last edited by dashingdude; 08-22-2007 at 03:47 AM.

  2. #2
    Registered User
    Join Date
    07-18-2007
    Posts
    10

    Fixed

    OK. I found the solution incase somebody is interested

    ---------------------------------

    Dim Filter As String, Title As String
    Dim FilterIndex As Integer
    Dim Filename As Variant

    ' File filters
    Filter = "Excel Files (*.xls),*.xls," & _
    "Text Files (*.txt),*.txt," & _
    "All Files (*.*),*.*"
    ' Default Filter to *.*
    FilterIndex = 3
    ' Set Dialog Caption
    Title = "Select a File to Open"
    ' Select Start Drive & Path
    ChDrive ("G")
    ChDir ("G:\ABCD\ABCD\4F Scores")
    With Application
    ' Set File Name to selected File
    Filename = .GetOpenFilename(Filter, FilterIndex, Title)
    ' Reset Start Drive/Path
    ChDrive (Left(.DefaultFilePath, 1))
    ChDir (.DefaultFilePath)
    End With
    ' Exit on Cancel
    If Filename = False Then
    MsgBox "No file was selected."
    Exit Sub
    End If
    ' Open File
    Workbooks.Open Filename
    MsgBox Filename, vbInformation, "File Opened" ' This can be removed
    Last edited by dashingdude; 08-16-2007 at 01:54 PM.

  3. #3
    Forum Contributor
    Join Date
    02-20-2007
    MS-Off Ver
    2003 & 2007
    Posts
    299
    how can you get the macro to open the file automatically without you clicking on it? In other words, the macro still opens that same path but you have coded what file to get and it opens it, does its thing, closes it, and you never have to click on it? - This would be very helpful for me.
    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