When you say "edited" I'm assuming you've changed this code snippet:
With oImage
.Left = oCell.Left
.Top = oCell.Top
.Width = oCell.Width
.Height = oCell.Height
End With
For this:
With oImage
.Left = oCell.Left
.Top = oCell.Top
.Width = oCell.Width / 1.2
.Height = oCell.Height / 1.2
End With
That is, in practice you have reduced the size of the image. So, to center the image in the cell (without worrying about how much factor has been applied), the easiest way is to add to the top coordinates ( Left
and Top
) half the cell size and decrease half the image size (which then needs to be calculated before , depending on the factor you are applying). Try it then:
factor = 1.2 ' Separei em uma variável só pra deixar claro que você pode
' mudar sem precisar mexer nas duas linhas finais.
With oImage
.Width = oCell.Width / factor
.Height = oCell.Height / factor
.Left = oCell.Left + oCell.Width / 2 - .Width / 2
.Top = oCell.Top + oCell.Height / 2 - .Height / 2
End With