1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
Option Explicit
Dim Cnn As ADODB.Connection
Dim Cmd As ADODB.Command
Dim rs As ADODB.Recordset
Dim StrSQL As String
Dim Row As Integer
Public Function Get_DSOCC() ' Appel pgm BIBLIO.MONPGM
Set Cnn = New ADODB.Connection
With Cnn
.Open "Provider=IBMDA400;Data Source=Adresse_IP_AS400;", "ProfilUSer", "MotDePasse"
End With
StrSQL = "BIBLIO.PROGRAMME" 'Nom programme AS400 qualifié avec un point
Set Cmd = New ADODB.Command
Set Cmd.ActiveConnection = Cnn
Cmd.CommandText = StrSQL
Cmd.CommandType = adCmdStoredProc
Set rs = New ADODB.Recordset
Set rs.Source = Cmd
Row = 0
rs.Open
While Not rs.EOF
' Calcule la ligne sur la feuille de calcul
Row = Row + 1
' Affiche la première colonne sur la feuille de calcul
With Worksheets("DSOCC")
.Cells(Row, 1).Value = rs(0)
End With
rs.MoveNext
Wend
rs.Close
Cnn.Close
Set Cnn = Nothing
Set Cmd = Nothing
Set rs = Nothing
End Function |
Partager