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
|
Sub GenerationPDF()
'procédure mettant à jour l'ensemble des fiches non obsolètes en PDF sur le réseau
Dim strSQl
Dim rs As DAO.Recordset
strSQl = "SELECT [Découpe ].NoFich, [Découpe ].Version, [Découpe ].[N°client JDE], [Découpe ].[Référence ORACLE], [Découpe ].[Fiche obsolete]" & _
"FROM [Découpe ]" & _
"WHERE ((([Découpe ].NoFich) <> 0) And (([Découpe ].[Fiche obsolete]) = False))"
Set rs = CurrentDb.OpenRecordset(strSQl)
rs.MoveFirst
Do While Not rs.EOF
PrintITDEtoPDF2007 rs.Fields(0), rs.Fields(1), rs.Fields(2), rs.Fields(3)
Debug.Print rs.Fields(0)
Debug.Print rs.RecordCount
rs.MoveNext
Loop
End Sub
Public Sub PrintITDEtoPDF2007(ByVal intIT As Long, ByVal intDE As Long, ByVal strCustomerID As String, ByVal strItem As String)
'https://msdn.microsoft.com/VBA/Access-VBA/articles/report-object-access
Dim strWhereClause As String
Dim i As Integer
strWhereClause = "[NoFich] = " & intIT & " AND [Version] = " & intDE
Debug.Print strWhereClause
DoCmd.OpenReport "Fiche Découpe PDF", acViewPreview, , strWhereClause
i = 0
Debug.Print Reports![Fiche Découpe PDF]![NoFich].Value
Debug.Print Reports![Fiche Découpe PDF]![Version].Value
'BOucle pour attendre que le pdf charge
Do While Not Reports![Fiche Découpe PDF]![Version].Value = intDE
DoCmd.OpenReport "Fiche Découpe PDF", acViewPreview, , strWhereClause
i = i + 1
If i > 10000 Then
MsgBox "error"
End If
Loop
DoCmd.OutputTo acOutputReport, "Fiche Découpe Atelier", acFormatPDF, "\\mondossier\" & intIT & "_" & intDE & "_" & strItem & "_" & strCustomerID & ".pdf"
'DoCmd.Close acReport, "Fiche Découpe Atelier"
DoCmd.Close acReport, "Fiche Découpe PDF"
End Sub |
Partager