Boa tarde!
Eu peguei um código de VBA na internet de redimensionar imagens. Fiz algumas adaptações do que copiei para uso na minha empresa, e eu queria que no final da execução da Macro aparecesse uma mensagem de "Concluído" somente uma vez. Porém, ele aparece pra todas as imagens que eu selecionar, ao invés de ser somente uma vez a mensagem. Por exemplo, se tiver 50 imagens no processo, a caixa aparece 50 vezes.
Como eu devo escrever o código para que seja somente uma vez?
O código é o seguinte:
Sub REDIMENSIONAR_IMAGENS()
Dim targetHeight As Integer
Dim oShp As Shape
Dim oILShp As InlineShape
targetHeight = InputBox("Indique a altura das imagens:", "Redimensionar Imagens")
If Trim(targetHeight) = 0 Then
MsgBox "Altura inválida", vbInformation, "Redimensionar Imagens"
End If
If Not Selection.ShapeRange Is Nothing Then
For Each oShp In Selection.ShapeRange
With oShp
.Width = AspectHt(.Height, .Width, CentimetersToPoints(targetHeight))
.Height = CentimetersToPoints(targetHeight)
End With
Next
End If
For Each oILShp In Selection.InlineShapes
With oILShp
.Width = AspectHt(.Height, .Width, CentimetersToPoints(targetHeight))
.Height = CentimetersToPoints(targetHeight)
End With
Next
End Sub
Private Function AspectHt(ByVal origWd As Long, ByVal origHt As Long, ByVal newWd As Long) As Long
If origWd <> 0 Then
AspectHt = (CSng(origHt) / CSng(origWd)) * newWd
Else
AspectHt = 0
End If
tratar:
MsgBox "Concluído"
End Function