Consulting

Results 1 to 3 of 3

Thread: Opening unknown File names in known Folder

  1. #1
    VBAX Regular
    Joined
    Oct 2018
    Posts
    43
    Location

    Opening unknown File names in known Folder

    Hello everyone,

    I am trying to open a xls unknown file in a known folder. But with no success so far. I googled it and find this code:

    Sub OpenFiles()Const FOLDER_NAME As String = "c:\Users\Edmond\Documents\Other"
    Dim NextFile As String
    
    
    NextFile = Dir(FOLDER_NAME & "*.xlsx", vbNormal)
    
    
    
    
    If (Len(NextFile) > 0) Then
      MsgBox "found " & NextFile
    End If
    
    
    End Sub

    Unfortunately, it doesn't work. Would you have an idea why?

    Many thanks in advance for your help
    Edmond

  2. #2
    There must be a pathseparator between FOLDERNAME and *.xlsx :
    NextFile = Dir(FOLDER_NAME & "\*.xlsx", vbNormal)
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    VBAX Regular
    Joined
    Oct 2018
    Posts
    43
    Location
    Great!! Thanks a lot!
    Edmond

Tags for this Thread

Posting Permissions

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