B
Bart Hernalsteen
Hi all,
I have the following problem : I resize the columns of a table that I have
created in the same macro.
When I run my code step by step (F8) It works
When I execute it it does not resize my columns.
I'm working with Word XP on Windows Xp.
Here's my code
' Define the range for the table
Set rngTable = ActiveDocument.Range(Start:=lngStart, End:=lngEnd)
' Convert the text to table
Set tblTable = rngTable.ConvertToTable(Separator:=wdSeparateByTabs,
AutoFitBehavior:=wdAutoFitFixed)
' Set the columnwidth for each column. The widths are stored in the
first Row
lngColumns = tblTable.Columns.Count
For intCount = 1 To lngColumns
dblWidth = Val(tblTable.Cell(1, intCount).Range.Text)
If dblWidth > 0 Then
tblTable.Columns(intCount).PreferredWidthType =
wdPreferredWidthPoints
tblTable.Columns(intCount).PreferredWidth =
CentimetersToPoints(dblWidth)
End If
Next intCount
Application.ScreenRefresh
DoEvents
I tried DoEvents and application.screenrefresh. No solution.
Can anyone help me ?
Thanks in advance
Bart
I have the following problem : I resize the columns of a table that I have
created in the same macro.
When I run my code step by step (F8) It works
When I execute it it does not resize my columns.
I'm working with Word XP on Windows Xp.
Here's my code
' Define the range for the table
Set rngTable = ActiveDocument.Range(Start:=lngStart, End:=lngEnd)
' Convert the text to table
Set tblTable = rngTable.ConvertToTable(Separator:=wdSeparateByTabs,
AutoFitBehavior:=wdAutoFitFixed)
' Set the columnwidth for each column. The widths are stored in the
first Row
lngColumns = tblTable.Columns.Count
For intCount = 1 To lngColumns
dblWidth = Val(tblTable.Cell(1, intCount).Range.Text)
If dblWidth > 0 Then
tblTable.Columns(intCount).PreferredWidthType =
wdPreferredWidthPoints
tblTable.Columns(intCount).PreferredWidth =
CentimetersToPoints(dblWidth)
End If
Next intCount
Application.ScreenRefresh
DoEvents
I tried DoEvents and application.screenrefresh. No solution.
Can anyone help me ?
Thanks in advance
Bart