Consulting

Results 1 to 2 of 2

Thread: Application.FileSearch replacement

  1. #1

    Application.FileSearch replacement

    hello today i wrote my second function and im just learning vba so dont judge pls my code looks like that:

    Public Sub OtworzKartke()
    Dim Szukanie As FileSearch
    Set Szukanie = Application.FileSearch
    
    
    
    
    Szukanie.Filename = "Kartka tarminarza.xls"
    Szukanie.LookIn = ThisWorkbook.Path
    
    
    If Szukanie.Execute(SortBy:=msoSortByFileName, SortOrder:=msoSortOrderAscending) > 0 Then Workbooks.Open (ThisWorkbook.Path & "\Kartka terminarza.xls")

    And as u can see i used Application.FileSearch which seems to dont work in excel 2016 and i was wondering how i can replace this to make my function work?

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    Application.FileSearch was deprecated over a decade ago and has not been supported in Office since Office 2007 was released. For what you're trying to do, the Dir function should suffice.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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