1) Execute o seguinte código no aplicativo Excel .
Sub Macro1()
'Delete all shapes if exists
For i = ActiveSheet.Shapes.Count To 1 Step -1
ActiveSheet.Shapes(i).Delete
Next i
'Add a Rectangle
With ActiveSheet.Shapes.AddShape(Type:=msoShapeRectangle, Left:=20, Top:=20, Width:=200, Height:=120)
.Name = "myRectangle"
End With
'Make some formatting to the myRectangle
With ActiveSheet.Shapes("myRectangle")
.Line.Visible = msoTrue
.Line.ForeColor.RGB = vbBlue
.Line.Weight = 5
.Fill.UserPicture "https://upload.wikimedia.org/wikipedia/en/b/ba/Flag_of_Germany.svg"
End With
End Sub
2) Verifique se você obteve o seguinte retângulo em sua planilha do Excel .
3) Estou procurando uma macro que me dê a seguinte imagem.
Como você pode entender, eu quero fazer algumas margens entre as bordas e a bandeira .
Por favor, tente
.PictureFormat.Crop
obter o resultado esperado.Documentação da Microsoft:
Há muitas abordagens que você pode tentar, talvez a mais simples seja adicionar outro retângulo menor no meio do primeiro: