Word VBA; set width of the cells after a split


I want to format a word table.

1. I want to catch the with of the current cell. (how can I doi this?)

2. I merge 2 cells,
Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend

Open in new window

3. then i to  
Selection.MoveRight Unit:=wdCell 

Open in new window

until I am on a new row

4 now, i do a split

Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend
Selection.Cells.Split NumRows:=1, NumColumns:=2, MergeBeforeSplit:=True

Open in new window

How do I set the width of the new cells? The width sould be the same as before the merge.

freundliche Grüsse

Ivo Raemy
Ivo RaemyAnalyst ProgrammerAsked:
Who is Participating?

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

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.

You now have a row with one fewer cells than the rest of the table followed by a row with an extra cell. If each cell width is to be the same, the left and/or right edge of the table will be ragged.
This macro assumes that the first cell in the table has the desired width. It leaves the right edge ragged.
Sub resizecells()
    Dim tbl As Table
    Dim cellwidth As Single
    Dim cl As Cell
    Set tbl = Selection.Tables(1)
    cellwidth = tbl.Range.Cells(1).width
    For Each cl In tbl.Range.Cells
        cl.width = cellwidth
    Next cl
End Sub

Open in new window

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
Ivo RaemyAnalyst ProgrammerAuthor Commented:
Dear Sir

I thank you for this solution. It suits my problem.

freundliche Grüsse

Ivo Raemy
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
Microsoft Word

From novice to tech pro — start learning today.