My Access application reads data from database tables and writes them to Excel, repeatedly making a new workbook and then making new worksheets therein, which are then filled with data and then formatted, stuff like:
Finally the workbook is saved, and the whole process is repeated for the next workbook. For some reason this works fine for the first workbook, but not for subseqent ones: evenything is written to Excel, but the formatting is not carried out; there are no error messages. The only way I have found that works, is to completely close Access, and then restart it to make the next workbook (just closing and reopening the application isn't enough). Any suggestions?
Code:
locNewRange = "A3:K" & Trim(Str(locRow_n))
objSht.Range(locNewRange).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
Selection.Borders(xlDiagonalUp).LineStyle = xlNone
With Selection.Borders(xlEdgeLeft)
.LineStyle = xlContinuous
.Weight = xlThin
.ColorIndex = xlAutomatic
End With
Finally the workbook is saved, and the whole process is repeated for the next workbook. For some reason this works fine for the first workbook, but not for subseqent ones: evenything is written to Excel, but the formatting is not carried out; there are no error messages. The only way I have found that works, is to completely close Access, and then restart it to make the next workbook (just closing and reopening the application isn't enough). Any suggestions?