Link to home
Start Free TrialLog in
Avatar of Sandra Smith
Sandra SmithFlag for United States of America

asked on

Open all workbooks with name in a particular pattern

I have an ACCESS 2003 process that, when the user hits the Open button, it opens ALL Excel workbooks that have a particular name pattern.  I can open one, but I need to loop through the folder and open everyone with this pattern.

Private Sub cmdTodaysWorkbook_Click()
'/SS - Opens all workbook created with today's date.
        Dim xlApp As Excel.Application
        Dim wbk As Workbook
        Dim strExistingFileName As String
        Dim fld As Object
        Dim strSource As String

strExistingFileName = "\\SF1\User1\shared\ATMVisalosses\ATMVisaLossesTST_" & Format(Now, "mm-dd-yyyy") & ""

Set xlApp = New Excel.Application
xlApp.Visible = True



    For Each fld In strSource.SubFolders
            Set wbk = xlApp.Workbooks.Open(strExistingFileName & "*.xlsx")
            xlApp.Workbooks.Open (strExistingFileName & "*.xlsx")
    Next

xlApp.WindowState = xlMaximized
Set xlApp = Nothing

End Sub
ASKER CERTIFIED SOLUTION
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sandra Smith

ASKER

Yes, it was getting around to the Like statement, I did not think it would work.

Sandra