Consulting

Results 1 to 2 of 2

Thread: Listing files in a folder with a powerpoint macro

  1. #1

    Listing files in a folder with a powerpoint macro

    In a Powerpoint (Office 2011) macro, I am trying to list all the files of a certain type in a folder.
    The subroutine I'm using to get the next file uses the statement "file = Dir()". Dir() is returning "", and not the next file.
    Dir is however returning a valid 1st file and CurDir is OK.
    Does anyone has a work around.

    The code I'm using is the following:

    Sub GetFileList(Extn, Path, nList, List())


    If Path = "" Then Path = CurDir
    Debug.Print Path



    fileID = 0 'Will still work if Mac files have the windoz extension
    Sym = ":"

    If LCase(Extn) = "wmf" Then fileID = MacID("WMF ")
    If LCase(Extn) = "jpg" Then fileID = MacID("JPEG")
    If LCase(Extn) = "gif" Then fileID = MacID("GIFf")
    If LCase(Extn) = "pct" Then fileID = MacID("PICT")
    If LCase(Extn) = "bmp" Then fileID = MacID("BMP ")

    file = Dir(Path & Sym, fileID)
    Debug.Print "file", file, fileID



    nList = 0

    Do While file <> "" ' Start the loop.

    If LCase(Right(file, 3)) = LCase(Extn) Then
    nList = nList + 1
    ReDim Preserve List(1 To nList)
    List(nList) = Path & Sym & file
    End If
    Debug.Print nList, List(nList)


    file = Dir() ' Get next entry.
    Debug.Print "file2", file
    Loop

    If nList > 0 Then Call Sort(nList, List)

    End Sub
    Last edited by jvbeaupre; 11-17-2014 at 04:26 PM. Reason: additional info

  2. #2
    I think in part, the problem came from having filenames that exceed some limit. So the old file name limits may be the limiting factor.

Posting Permissions

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