Macro to set tab stops

What macro code would set the tab stops on all selected text to the values I want?
Answer
Answer

Assuming they're all left tab-stops with no leaders, you could use a macro like:

Sub Demo()
Application.ScreenUpdating = False
Dim StrStops As String, i As Long
StrStops = "0.5,1,1.5,1.75,2,2.1"
With Selection.Range.ParagraphFormat
  For i = 0 To UBound(Split(StrStops, ","))
    .TabStops.Add (InchesToPoints(Split(StrStops, ",")(i)))
  Next
End With
Application.ScreenUpdating = True
End Sub

Extra code & logic could be added for different tab alignments & leaders.

This would really only be useful if you want to add the same tab stops to multiple selections. In that case, however, you really would do better to define a Style using a paragraph format with the required tab-stops and apply that to the selections.

Cheers
Paul Edstein
(Fmr MS MVP - Word)

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated April 14, 2025 Views 414 Applies to: