Hi, we are converting our sql queries (done thru Excel) into Stored Procedures. I have figured out how to call a stored procedure, but I do not know how to pass parameters. I have my parameters that were used in the original queries as comments at the top. Then the code is calling a stored procedure. Can someone help me with the parameter part?
'parameters used in queries:
'
'offnum = Range("OfficeValue")  
'  This is a number and in the SQL query would look like: '24' or '667' - it is an integer
'
'*******
'If frmInput.obPartner.Value = True Then
'    Pname = frmInput.ComboNames.Value    This is a name like 'Smith' - is varchar, 20
'    Bname = ""
'Else
'    Bname = frmInput.ComboNames.Value    This is a name like 'Smith' - is varchar, 20
'    Pname = ""
'End If
'*******

Sub CallStoredProcedure()

Dim oConn As New ADODB.Connection
Dim oRs As ADODB.Recordset
Dim cmd As New ADODB.Command
Dim stProcName As String
   

'Open a connection.
Set oConn = New ADODB.Connection
oConn.Open strConnect
Set oRs = New ADODB.Recordset

oConn.CommandTimeout = 1200


stProcName = "STORED PROCEDURE NAME HERE"
cmd.CommandType = adCmdStoredProc
cmd.ActiveConnection = oConn
cmd.CommandText = stProcName


Set oRs = New ADODB.Recordset
oRs.Open cmd.Execute

'where to put data
Sheet4.Range("A2").CopyFromRecordset oRs

     
' Close the connection.
oRs.Close
oConn.Close

End Sub