View Single Post
 
Old 03-17-2015, 10:03 AM
dherr dherr is offline Windows 8 Office 2007
Advanced Beginner
 
Join Date: Nov 2014
Location: Austria
Posts: 45
dherr is on a distinguished road
Default Table formatting- column widths to percent

Hi,
I want to set the columns of a table to procentual values and have written the following code:
Code:
Sub setProz(tb As Word.table, prozentual As Variant)
    Dim i As Integer, co As Integer
    With tb
        .PreferredWidthType = wdPreferredWidthPercent
        co = .columns.Count
        For i = 0 To co - 1
            .columns(i + 1).PreferredWidth = Val(prozentual(i))
        Next
    End With
End Sub
The parameters are first a table, second an array, for instance
Array(10, 50, 20, 20) when the table has 4 columns.
The problem is when I use this code, the table doesn't change the column widths at normal runtime.
When I set a debugging breakpoint to the line 'End Sub' the table changes after a second.
I tried to 'refresh' or 'update' the table, but no success...
What's to do?

Regards-
Dietrich
Reply With Quote