In einem Worddokument habe ich mehrere Bilder welche mit folgendem Skript alle auf die gleiche Grösse gebracht werden sollen:
Private Sub CommandButton1_Click()
Dim objPic As Object
For Each objPic In ActiveDocument.InlineShapes
With objPic
.LockAspectRatio = msoFalse
.Width = Application.CentimetersToPoints(4.2)
.Height = Application.CentimetersToPoints(5.6)
End With
Next
End Sub
Das funktioniert auch einwandfrei.
Das Problem ist nun, dass alle CommandButtons auch auf diese Grösse skaliert werden. Mir schwebt als Lösung eine vorangestellte IF-Abfrage vor. Ich kenne mich in VBA jedoch nicht besonders gut aus, daher brauche ich eure Hilfe.
Schema:
Schleife für alle objPic. Wenn objPic ein CommandButton, dann tue nichts, ansonsten skaliere sie mit dem Script wie oben beschrieben.
Hier mein Anfang um das Problem zu lösen:
Private Sub CommandButton1_Click()
Dim objPic As Object
For Each objPic In ActiveDocument.InlineShapes
If objPic = CommandButton1 Then
Beep
Else
With objPic
.LockAspectRatio = msoFalse
.Width = Application.CentimetersToPoints(4.2)
.Height = Application.CentimetersToPoints(5.6)
End With
End If
Next
End Sub
Vielen Dank für eure Hilfe
Lukas