Results 1 to 2 of 2
  1. #1
    3 Star Lounger
    Join Date
    Feb 2003
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Finding a wbk in a known directory (2003)

    I want the user to select one of several workbooks located in ThisWorkbook.Path & "BACKUP"
    All files in this folder should have titles of : "MyData 2008-02-15.xls" (with the date only varying).
    Once the file is identified, I may or may not actually open it.

    What is the code needed for this?
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Finding a wbk in a known directory (2003)

    Something like this:

    Sub Test()
    Dim strFile As String
    Dim strPath As String
    strPath = ThisWorkbook.Path & "MyData*.xls"
    With Application.FileDialog(msoFileDialogFilePicker)
    .Filters.Clear
    .Filters.Add "Excel workbooks", "*.xls"
    .InitialFileName = strPath
    If .Show Then
    strFile = .SelectedItems(1)
    End If
    End With
    If strFile = "" Then
    MsgBox "No file selected", vbInformation
    Else
    MsgBox "You selected " & strFile, vbInformation
    End If
    End Sub

Posting Permissions

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