Results 1 to 3 of 3

Thread: Macro to open a workbook whose name changes regularly

  1. #1

    Question Macro to open a workbook whose name changes regularly



    Register for a FREE account, and/
    or Log in to avoid these ads!

    Hello everyone
    I am trying to write a macro that opens a workbook which is in a specific location. The workbook changes name regularly according to the date it is saved on. But there is only one *.xls file at this location. The location is E:\Reports. The latest filename is 11-3-2014.xls. My attempts doing this have failed so far. ? I would very much like the macro to find this *.xls file and open it, whatever the name will be.
    Can anyone help?

    Brg. Not an excel guru

  2. #2
    Conjurer Simi's Avatar
    Join Date
    Feb 2012
    Location
    Utah, USA
    Posts
    187
    Articles
    0
    This can be done, and I seem to be referring to this other thread a lot lately.
    check this post, http://www.excelguru.ca/forums/showt...ht=consolidate
    You can use the File Scripting Object as Ken explains in the post.

  3. #3
    Acolyte patel's Avatar
    Join Date
    Feb 2014
    Location
    Italy
    Posts
    59
    Articles
    0
    Code:
    Sub OpenFileNoName()
      fpath = "E:\Reports\"
      FoundFile = Dir(fpath & "*.xls")
      If FoundFile <> "" Then
            Workbooks.Open (fpath & FoundFile)
      Else
            MsgBox "No such file!"
      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
  •