Application definned or object defined error
i have a program in which i want to transfer the data from any sql server 6.0 into excel 97
but i got the errror on line which i indicated below in the pograme
Dim con As ADODB.Connection
Dim rs As ADODB.Recordset
Dim squery As String
Dim xlApp As Object
Dim xlWb As Object
Dim xlWs As Object
Private Sub cmdoutput_Click()
Dim reccount As Variant
Dim recarray As Variant
Dim fldcount As Variant
Set con = New ADODB.Connection
Set rs = New ADODB.Recordset
con.Open "Driver={SQL Server};Server=" & listserver & "; Database=shrmgmtDb;Uid=sa;Pwd=" & txtpassword & ";"
squery = "select * from output"
rs.Open squery, con1, adOpenDynamic, adLockBatchOptimistic, adCmdText
Set xlApp = CreateObject("Excel.Application")
Set xlWb = xlApp.Workbooks.Open("c:\fin.xls")
Set xlWs = xlWb.Worksheets("sheet1")
xlApp.Visible = True
fldcount = rs.Fields.Count
recarray = rs.GetRows
reccount = UBound(recarray, 2) + 1
xlWs.Cells(i, 10).Resize(reccount, fldcount) = Transpose(recarray)<----- here is the error----->
rs.Close
con.Close
Set rs = Nothing
Set con = Nothing
end sub
Function Transpose(v As Variant) As Variant
Dim Xupper, Yupper, x, y As Long
Dim temparray As Variant
Xupper = UBound(v, 2)
Yupper = UBound(v, 1)
ReDim temparray(Xupper, Yupper)
For x = 0 To Xupper
For y = 0 To Yupper
temparray(x, y) = v(y, x)
Next y
Next x
Transpose = temparray
End Function

