Hello everyone. First of all thanks for the support. You are great!
I know I'm probably making a really dumb mistake in my code but I can't make it out.
There are three Subs: 1) increase the margin up to a size of 1,5cm; 2) decrease; and 3) reset margins to 0.
The increase works but ignores de the 1,5 cm limiter. Same happens with the decrease which ignores the 0 limit. The reset works fine.
Thanks in advance for your help!
Option Explicit
Const MarginMax = 28.35 * 1#
Const MarginIncrement = 28.35 * 0.05
Sub marginincrease()
Dim oshp As Shape
For Each oshp In ActiveWindow.Selection.ShapeRange
If oshp.HasTextFrame Then
With oshp.TextFrame
If .MarginBottom >= 0 Or .MarginBottom <= MarginMax Then .MarginBottom = .MarginBottom + MarginIncrement
If .MarginLeft >= 0 Or .MarginLeft <= MarginMax Then .MarginLeft = .MarginLeft + MarginIncrement
If .MarginTop >= 0 Or .MarginTop <= MarginMax Then .MarginTop = .MarginTop + MarginIncrement
If .MarginRight >= 0 Or .MarginRight <= MarginMax Then .MarginRight = .MarginRight + MarginIncrement
End With
End If
Next
End Sub
Sub margindecrease()
Dim oshp As Shape
For Each oshp In ActiveWindow.Selection.ShapeRange
If oshp.HasTextFrame Then
With oshp.TextFrame
If .MarginBottom >= 0 Or .MarginBottom <= MarginMax Then .MarginBottom = .MarginBottom - MarginIncrement
If .MarginLeft >= 0 Or .MarginLeft <= MarginMax Then .MarginLeft = .MarginLeft - MarginIncrement
If .MarginTop >= 0 Or .MarginTop <= MarginMax Then .MarginTop = .MarginTop - MarginIncrement
If .MarginRight >= 0 Or .MarginRight <= MarginMax Then .MarginRight = .MarginRight - MarginIncrement
End With
End If
Next
End Sub
Sub noMargins()
Dim oshp As Shape
For Each oshp In ActiveWindow.Selection.ShapeRange
If oshp.HasTextFrame Then
With oshp.TextFrame
.MarginBottom = 0
.MarginLeft = 0
.MarginTop = 0
.MarginRight = 0
End With
End If
Next
End Sub