Rx_
Nothing In Moderation
- Local time
- Today, 09:09
- Joined
- Oct 22, 2009
- Messages
- 2,803
Pretty simple really. Some code opens up an Excel Template. Using a start location, it copyfromrecordset to populate the Excel document.
The data is a Linked SQL Server table.
Why is one view so much slower (100 times slower) than the others.
general process: Open a template, populate data, save as, close the workbook, then use a loop to do the same thing 9 times (nine linked tables).
There are 9 tables.
Eight of these take about 8.3 seconds each to create and save.
Except for the linked table with T&D in the name. It takes 6.4 Minutes!
Ok, it is about 3 times as many records a total of 1,500 records.
All of the linked views are the exact same format.
All the Linked Tables are actually just a Table Level View from the same source on SQL Server.
The data is a Linked SQL Server table.
Why is one view so much slower (100 times slower) than the others.
general process: Open a template, populate data, save as, close the workbook, then use a loop to do the same thing 9 times (nine linked tables).
There are 9 tables.
Eight of these take about 8.3 seconds each to create and save.
Except for the linked table with T&D in the name. It takes 6.4 Minutes!
Ok, it is about 3 times as many records a total of 1,500 records.
All of the linked views are the exact same format.
All the Linked Tables are actually just a Table Level View from the same source on SQL Server.
Code:
On Error GoTo err_trap
Set rs = DB.OpenRecordset(TableName)
ObjXL.Workbooks(1).Worksheets(TabName).Select '
ObjXL.Range(StartLocation).Select
ObjXL.ScreenUpdating = False
ObjXL.Calculation = xlCalculationManual ' turn Off Excel calculation
ObjXL.EnableEvents = False
ObjXL.ActiveSheet.DisplayPageBreaks = False
ObjXL.Workbooks(1).Worksheets(TabName).Range(StartLocation).CopyFromRecordset rs
ObjXL.ScreenUpdating = True
ObjXL.Calculation = xlCalculationAutomatic 'To turn Off the automatic calculation
ObjXL.EnableEvents = True
ObjXL.ActiveSheet.DisplayPageBreaks = True
ObjXL.Columns("A:" & LastDatacolumn).Select