Set Decimal Tabstops (1.7 cm) in Column 2 and Column 3 for tables 2 to penultimate one (Using VBA)

Dear experts:

I would like to set decimal tabstops (position 1.7 cm) in Column 2 and Column 3 for tables 2 to the penultimate one of the currently active document (running a macro). The header rows should be left alone, i.e. no decimal tab stops for the header rows.

I have attached a sample for your convenience. In Germany we use a comma as a decimal point. Word for Windows might convert that to a 'dot / point' if you open it on your PC in an angloamerican country or India.

Help is much appreciated. Thank you very much in advance

Set_Decimal_TabStops_Tables.docx
Regards, Andreas
Andreas HermleTeam leaderAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

GrahamSkanRetiredCommented:
Hi Andreas
The carers have just put my partner to bed, so I can relax with this.
Sub SetDecimalTabStops()
    Dim tbl As Table
    Dim r As Integer
    Dim c As Integer
    Dim para As Paragraph
    Dim t As Integer
    
    For t = 2 To ActiveDocument.Tables.Count - 1
        Set tbl = ActiveDocument.Tables(t)
        For c = 2 To 3
            For r = 2 To tbl.Rows.Count
                Set para = tbl.Cell(r, c).Range.Paragraphs.First
                para.TabStops.ClearAll
                para.TabStops.Add CentimetersToPoints(1.7), wdAlignTabDecimal
             Next r
        Next c
    Next t
    
End Su

Open in new window

b
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Andreas HermleTeam leaderAuthor Commented:
Great Graham, works like a charm. Thank you very much, I really appreciate it.

And all the best

Kind regards, Andreas
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.