Private Sub cmdGetReport_Click()
Dim strConn As String
Dim actcol, actrow, iCols As Integer
strConn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist
Security Info=False;Initial Catalog=vdb;Data Source=test"
Set conn = New ADODB.Connection
conn.Open strConn
Set cmdBudget = New ADODB.Command
cmdBudget.ActiveConnection = conn
cmdBudget.CommandText = "hesri_test"
cmdBudget.CommandType = adCmdStoredProc
Set rstBudget = cmdBudget.Execute()
' Get the active colum and row position (This will be parameter
value 1)
actcol = ActiveCell.Column
actrow = ActiveCell.Row
'Return results on to the current worksheet at the row below the
' active cell location and include a header colum in bold text
For iCols = 0 To rstBudget.Fields.Count - 1
ActiveSheet.Cells(actrow + 1, actcol + iCols).Value =
rstBudget.Fields(iCols).Name
Next iCols
ActiveSheet.Range(ActiveSheet.Cells(actrow + 1, actcol),
ActiveSheet.Cells(actrow + 1, actcol + rstBudget.Fields.Count -
1)).Font.Bold = True
ActiveSheet.Cells(actrow + 2, actcol).CopyFromRecordset
rstBudget 'datastarts at row+2
MsgBox ("data loaded")
End Sub
note: this sp takes atleast 20 mins to execute