The following code in theory should resize my excel tables when run from Access. I receive no errors when this is run but the tables in my excel file do not resize to all the data in the worksheets. Any help is much appreciated!
Dim appExcel As Object
Dim stWorkbook As Object
Dim varName
Set appExcel = CreateObject("Excel.Application")
Set stWorkbook = appExcel.Workbooks.Open("G:\Home\RiskMgtReports\Reporting Database\Excel\DealerProfit.xlsx")
For Each varName In Array("DLR_ALL", "DLR_ACTIVE_DESC", "DLR_ACTIVE_ALPHA", "DLR_ACTIVE_UPF", "DLR_TERM_ALPHA", "DLR_TERM_DESC")
With stWorkbook.Worksheets(varName).ListObjects("tbl" & varName)
.Resize stWorkbook.Worksheets(varName).Range(varName)
With .DataBodyRange
.Interior.Pattern = xlNone
.Borders.LineStyle = xlNone
End With
End With
Next varName
stWorkbook.Close SaveChanges:=True
appExcel.Quit
Set appExcel = Nothing