Reputation: 1911
I have a code that is working regarding insertion of a photo, but I can't send it to back.
I've tried from this post to copy line .ZOrder, but I am operating with object not shape..
Here is mine code:
Private Sub CommandButton13_Click()
Dim p As Object
Dim rng0 As Range
Dim sh As Worksheet: Set sh = ActiveSheet
Set rng0 = Range("Q3:S5")
Application.ScreenUpdating = False
If UserForm1.txtImage = "" Then
rng0.Borders(xlEdgeBottom).LineStyle = xlContinuous
Exit Sub
Else
sh.Range("Q3:S5").Merge
Set p = sh.Pictures.Insert(UserForm1.txtImageBackground)
sh.Shapes(p.name).LockAspectRatio = False
If rng0.Cells.Count = 1 Then Set rng0 = rng0.MergeArea
With rng0
p.Top = .Top
p.Left = .Left
p.Width = .Width
p.Height = .Height
End With
Application.ScreenUpdating = True
End If
Selection.ShapeRange.ZOrder msoSendToBack
Application.ScreenUpdating = True
' shp.ScaleHeight Factor:=1, RelativeToOriginalSize:=msoTrue
' shp.ScaleWidth Factor:=1, RelativeToOriginalSize:=msoTrue
' shp.ZOrder msoSendToBack
End Sub
Thanks!
Upvotes: 0
Views: 670
Reputation: 34075
p
is a Picture
so you can use ZOrder
on it directly:
p.ZOrder msoSendToBack
Edit: my mistake. Zorder
is a property for Pictures and is read-only. You need:
p.ShapeRange.ZOrder msoSendToBack
Upvotes: 1