Search code examples
vbapowerpoint

How to add color border to image in [vba] [powerpoint]


I need to add border to different images that I have in a power point presentation, I am also looking for how to send the image to the background behind the letters. Can someone help me

Sub ajustar2()

'imagenes  segunda diapo'

Set imagen1 = ActivePresentation.Slides(2)
imagen1.Shapes.AddPicture FileName:="D:\I\P\h.png", LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, _
    Left:=10, Top:=75, Width:=433, Height:=330
    
Set imagen2 = ActivePresentation.Slides(2)
imagen2.Shapes.AddPicture FileName:="D:\I\P\d.png", LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, _
    Left:=463, Top:=75, Width:=484, Height:=330

'imagenes  tercera diapo'

Set imagen1 = ActivePresentation.Slides(3)
imagen1.Shapes.AddPicture FileName:="D:\I\P\h.png", LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, _
    Left:=10, Top:=75, Width:=433, Height:=330
    
Set imagen2 = ActivePresentation.Slides(3)
imagen2.Shapes.AddPicture FileName:="D:\I\P\v.png", LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, _
    Left:=463, Top:=75, Width:=484, Height:=330
    
    ActivePresentation.Slides(2).Select
    Selection.ShapeRange.ZOrder msoSendToBack

End Sub

Solution

  • using Picture as Shape object and editing it's properties

    Sub ajustar2()
    Dim imagen1 As Slide, pic As Shape
    Set imagen1 = ActivePresentation.Slides(1)
    Set pic = imagen1.Shapes.AddPicture(FileName:="D:\INFORMES\PILAS\hazard.png", _
                LinkToFile:=msoTrue, SaveWithDocument:=msoTrue, Left:=10, Top:=75, _
                Width:=433, Height:=330)
    With pic
    .Line.Weight = 5
    .Line.ForeColor.RGB = RGB(255, 0, 0) 'choose RGB color combination
    .ZOrder (msoSendToBack)
    
    End With
    End Sub