How to Round Up Paragraph Indent Values

• Question

• Hi Everybody,

I have a document which contain some bizarre left indents and first line indents such as 0.888793, 0.1138889, 6.944445E-02, 7.222222E-02, 2.163194. I have no idea how this happened. These values not showing in paragraph format box but returned values when im trying to change indents with a macro. So i thought it would be best to round these values to 2 decimal places. I have a small code which i have written but it doesn't work.

Sub test()
Dim para As Paragraph

For Each para In ActiveDocument.Paragraphs

If para.FirstLineIndent > 0 Then
para.FirstLineIndent = Math.Round(para.FirstLineIndent, 2)
End If

Next

End Sub

I'm not very familiar with this round function. If anyone can help me through this I'm very much obliged.

Regards,
___________________________________
Supun Samarakoon

Regards, __________________________________ Supun Samarakoon

Tuesday, October 18, 2016 11:37 AM

• Indents are measured in points, where 1 point = 1/72 inch = 0.013888... inch.

So for example if you set FirstLineIndent to 10 (points), this will correspond to 0.13888... inch.

If you want to round the indents in inches to 2 decimal places, you can use

para.FirstLineIndent = Application.InchesToPoints(Round(Application.PointsToInches(para.FirstLineIndent), 2))

Regards, Hans Vogelaar (http://www.eileenslounge.com)

• Marked as answer by Tuesday, October 18, 2016 5:04 PM
Tuesday, October 18, 2016 3:01 PM

All replies

• Indents are measured in points, where 1 point = 1/72 inch = 0.013888... inch.

So for example if you set FirstLineIndent to 10 (points), this will correspond to 0.13888... inch.

If you want to round the indents in inches to 2 decimal places, you can use

para.FirstLineIndent = Application.InchesToPoints(Round(Application.PointsToInches(para.FirstLineIndent), 2))

Regards, Hans Vogelaar (http://www.eileenslounge.com)

• Marked as answer by Tuesday, October 18, 2016 5:04 PM
Tuesday, October 18, 2016 3:01 PM
• Thanks you very much Hans,

It works. I think I completely forgot the unit conversion factor here. Thanks Friend. Really appreciate it.

Regards,

Supun Samarakoon

• Edited by Tuesday, October 18, 2016 5:06 PM
Tuesday, October 18, 2016 5:06 PM