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 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
| 'slide6
sourcePresentation.Slides(6).Copy
destinationPresentation.Slides.Paste
Set slide = destinationPresentation.Slides(6)
' Exécutez la requête SQL
Dim strSQL As String
Dim sfamSpacing As Single
Dim nam_art As String
Dim img As Boolean
Dim imag As String
Dim imgShape As shape
Dim artShape As shape
Dim firstImageLeftPosition As Single
Dim topPositionMax As Single ' Nouvelle variable pour définir la limite de la position verticale
Dim imgPosition As Single
strSQL = "SELECT sfam, nam_art, img, imag FROM r_exp_art_prest WHERE id_aff = " & id_aff & " ORDER BY order2"
' Ouvrez un enregistrement recordset
Set rs = db.OpenRecordset(strSQL)
expSfam = ""
topPosition = 100 ' À ajuster selon votre mise en page
sfamSpacing = 60 ' Valeur de l'espace supplémentaire entre chaque sfam
topLeft = 74.844
firstImageLeftPosition = topLeft
topPositionMax = 350 ' Nouvelle variable pour définir la limite de la position verticale
' Parcourez les enregistrements résultants de la requête
Do While Not rs.EOF
sfam = rs!sfam
nam_art = rs!nam_art
img = rs!img
imag = rs!imag
' Si la valeur de sfam change, créer une nouvelle catégorie (sfam)
If sfam <> expSfam Then
' Vérifier si la position verticale atteint la limite
If topPosition > topPositionMax Then
If topLeft = 480 Then
' Copier la slide 6 du sourcePresentation
sourcePresentation.Slides(6).Copy
' Coller la slide copiée à la fin du destinationPresentation
destinationPresentation.Slides.Paste
' Définir slide comme étant la dernière diapositive ajoutée
Set slide = destinationPresentation.Slides(destinationPresentation.Slides.Count)
topPosition = 40 ' Réinitialisation de la position verticale
topLeft = 74.844 ' Réinitialisation de la position horizontale
End If
' Exporter le contenu de la famille en réinitialisant la position verticale et horizontale
topPosition = 40 ' Réinitialisation de la position verticale
topLeft = 480 ' Réinitialisation de la position horizontale
End If
' Ajouter un espace supplémentaire entre les sfam
If expSfam <> "" Then
topPosition = topPosition + sfamSpacing
End If
' Afficher le nom de la famille (sfam)
Set shape = slide.Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=topLeft, Top:=topPosition, Width:=400, Height:=17.01)
shape.TextFrame.TextRange.Text = sfam
With shape.TextFrame.TextRange.Font
.Size = 11
.Name = "Century Gothic"
.Color.RGB = RGB(0, 0, 0) ' Rouge: 0, Vert: 0, Bleu: 0
.Bold = True
End With
' Mettre à jour la position verticale
topPosition = topPosition + 20 ' À ajuster selon votre mise en page
' Réinitialiser expSfam
expSfam = sfam
firstImageLeftPosition = topLeft ' Réinitialisation de la position horizontale
End If
' Afficher le nom de l'article (nam_art)
Set artShape = slide.Shapes.AddTextbox(msoTextOrientationHorizontal, Left:=topLeft, Top:=topPosition, Width:=400, Height:=17.01)
artShape.TextFrame.TextRange.Text = nam_art
With artShape.TextFrame.TextRange.Font
.Size = 11
.Name = "Century Gothic"
.Color.RGB = RGB(0, 0, 0) ' Rouge: 0, Vert: 0, Bleu: 0
End With
imgPosition = topPosition + artShape.Height
topPosition = topPosition + 12
' Vérifier si le champ "img" est défini sur "Oui" et afficher l'image
If img = True Then
' Assurez-vous que "imag" contient l'adresse de l'image
If imag <> "" Then
' Créer un objet Image à la position actuelle (leftPosition)
Set imgShape = slide.Shapes.AddPicture(FileName:=imag, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=firstImageLeftPosition, Top:=imgPosition + CalculateVerticalOffset(imag))
' Mettre à jour la position horizontale pour la prochaine image dans la même famille
firstImageLeftPosition = firstImageLeftPosition + 60 ' Ajustez cette valeur selon la largeur de vos images
End If
End If
' Mettre à jour la position verticale
'topPosition = topPosition + 12 ' À ajuster selon votre mise en page
rs.MoveNext
Loop
' Fermez le recordset
rs.close |
Partager