Open all workbooks with name in a particular pattern
Posted on 2013-06-05
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")
xlApp.WindowState = xlMaximized
Set xlApp = Nothing