Do While Not Adodc1.Recordset.EOF
xlapp.Cells(i, 1) = Adodc1.Recordset.Fields(0)
With xlapp.Cells(i, 1).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 2) = Adodc1.Recordset.Fields(1)
With xlapp.Cells(i, 2).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 3) = Adodc1.Recordset.Fields(2)
With xlapp.Cells(i, 3).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 4) = Adodc1.Recordset.Fields(3)
With xlapp.Cells(i, 4).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 5) = Adodc1.Recordset.Fields(4)
With xlapp.Cells(i, 5).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 6) = Adodc1.Recordset.Fields(5)
With xlapp.Cells(i, 6).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 7) = Adodc1.Recordset.Fields(6)
With xlapp.Cells(i, 7).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 8) = Adodc1.Recordset.Fields(7)
With xlapp.Cells(i, 8).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 9) = Adodc1.Recordset.Fields(8)
With xlapp.Cells(i, 9).Borders
.LineStyle = 1
.Weight = 2
End With
xlapp.Cells(i, 10) = Adodc1.Recordset.Fields(9)
With xlapp.Cells(i, 10).Borders
.LineStyle = 1
.Weight = 2
End With
Adodc1.Recordset.MoveNext
i = i + 1
Loop
'
With Sheets("sheet1").Range(Cells(4, 1), Cells(3 + n, 10)).Borders
' .LineStyle = 1
' .Weight = 2
'
End With
以上修改暂时都通过了。各种测试均正常。最终原因还是没找到。