PDA

View Full Version : Decreasing Internal Margins for a shape (PowerPoint)



Rosenrot
10-14-2019, 07:34 AM
Hi,

I created the macro which incrementally decreases the internal margins of shapes (by 0.1 cm.).

I wonder if there is any way to make this code go further and ignore the numbers which are smaller than 0.1 cm.

For example, if I set all the shape's margins to 0.26 cm I can only click twice and then the error raised “The specified value is out of range”. I would like to ignore the remaining 0.06 cm and set the value to 0 cm after the third click.

I would be more than grateful for any suggestions how to solve this!



Sub Decrease_01cm_Shape()
With ActiveWindow.Selection.ShapeRange.TextFrame2
.MarginLeft = .MarginLeft - 2.8346456693
.MarginRight = .MarginRight - 2.8346456693
.MarginBottom = .MarginBottom - 2.8346456693
.MarginTop = .MarginTop - 2.8346456693
End With
End Sub

John Wilson
10-16-2019, 04:03 AM
Something like this maybe:




Sub sngDecrease_01cm_Shape()


Const sngDec As Single = 2.834645
With ActiveWindow.Selection.ShapeRange.TextFrame2
If .MarginLeft - sngDec > 0.1 Then .MarginLeft = .MarginLeft - sngDec
If .MarginRight - sngDec > 0.1 Then .MarginRight = .MarginRight - sngDec
If .MarginTop - sngDec > 0.1 Then .MarginTop = .MarginTop - sngDec
If .MarginBottom - sngDec > 0.1 Then .MarginBottom = .MarginBottom - sngDec
End With
End Sub