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 49 50 51 52 53 54 55 56 57 58 59 60 61 62
| Private Sub Form_Current()
Dim cnc As New ADODB.Connection
Dim rst As New ADODB.Recordset
Dim TotPrest As Variant
Dim TotPr As Variant
Dim ChConcat()
Dim cumul As String
Dim tbl()
Dim Control As Control
Set cnc = CurrentProject.Connection
rst.Open "Tbl_Projet", cnc ' , adOpenDynamic, adLockBatchOptimistic
nb = DMax("Projet", "tbl_Projet")
ReDim ChConcat(nb)
ReDim tbl(1 To 2, 1 To nb)
For i = 1 To nb
rst.MoveFirst
While Not rst.EOF
If rst("Projet") = i Then
cumul = cumul & " " & rst("NomParticipant")
End If
rst.MoveNext
Wend
ChConcat(i) = cumul
NomCont = "Texte" & i
For Each Control In Me.Controls
If Control.Name = NomCont Then
Control.Value = ChConcat(i)
Exit For
End If
Next
tbl(1, i) = i
tbl(2, i) = cumul
cumul = ""
Next i
Dim Canal As Variant
Dim strExcel As String
strExcel = "C:\Program Files\Microsoft Office\Office12\EXCEL.exe"
blnRes = Shell(strExcel, vbNormalFocus)
Canal = DDEInitiate("Excel", "Classeur1")
DDEPoke Canal, "L1C1", "Projet"
DDEPoke Canal, "L1C2", "NomParticipant"
For i = 1 To nb
proj1 = "L" & i + 1 & "C1"
NomP = "L" & i + 1 & "C2"
proj = tbl(1, i)
NomPart = tbl(2, i)
DDEPoke Canal, proj1, proj
DDEPoke Canal, NomP, NomPart
Next i
rst.Close
cnc.Close
End Sub |
Partager