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
|
Function RangeCopyToPPT(myRange As Range, mySlide As PowerPoint.Slide) As PowerPoint.Shape
Dim l_max As Integer, c_max As Integer, l As Integer, c As Integer
Dim Forme As PowerPoint.Shape
Dim MonAlignement As Long
l_max = myRange.Rows.count
c_max = myRange.Columns.count
'Ajout d'un tableau
Set Forme = mySlide.Shapes.AddTable(l_max, c_max)
Forme.Table.FirstRow = False
Forme.Table.HorizBanding = False
For l = 1 To l_max
For c = 1 To c_max
'Copie des valeurs
If myRange.Cells(l, c).NumberFormat <> "General" Then 'Récupération du format des nombres
Forme.Table.Cell(l, c).Shape.TextFrame.TextRange.Text = Format(myRange.Cells(l, c), myRange.Cells(l, c).NumberFormat)
Else
Forme.Table.Cell(l, c).Shape.TextFrame.TextRange.Text = myRange.Cells(l, c)
End If
'Copie de la mise en forme
Forme.Table.Cell(l, c).Shape.Fill.ForeColor.RGB = myRange.Cells(l, c).Interior.Color
Forme.Table.Cell(l, c).Shape.TextFrame.TextRange.Font.Name = myRange.Cells(l, c).Font.Name
Forme.Table.Cell(l, c).Shape.TextFrame.TextRange.Font.Size = myRange.Cells(l, c).Font.Size
Forme.Table.Cell(l, c).Shape.TextFrame.TextRange.Font.Color = myRange.Cells(l, c).Font.Color
'Récupération alignement
Select Case myRange.Cells(l, c).HorizontalAlignment
Case xlLeft
MonAlignement = ppAlignLeft
Case xlRight
MonAlignement = ppAlignRight
Case Else
MonAlignement = ppAlignCenter
End Select
Forme.Table.Cell(l, c).Shape.TextFrame.TextRange.ParagraphFormat.Alignment = MonAlignement
Next c
Next l
Set RangeCopyToPPT = Forme
End Function |
Partager