Identifying zero width columns

P

Phil Caisley

We have created a Word to XML conversion routine that copes with most
things we throw at it. We are however experiencing a problem where the
column widths of Word tables have become 'corrupted' over time
resulting in zero width columns. These zero width columns are
throwing out our conversion routine.

Has anyone found a way of identifying a zero width column and secondly
has anyone found a way of fixing the column width without rekeying the
entire table?

I would be grateful for any help/experience you have on this problem.

Thanks in advance,
Phil
 
J

JGM

Hi Phil,

I am curious about your "zero width" columns. I have never seen that...

You may want to try something like:

'_______________________________________
Dim myDoc As Document
Dim myTable As Table
Dim myCol As Column

Set myDoc = ActiveDocument
Set myTable = Selection.Tables(1)
'or to control which table is selected
'Set myTable = myDoc.Tables(1)


For i = 1 To myTable.Columns.Count
Set myCol = myTable.Columns(i)
If myCol.Width = 0 Then
'or
' If myCol.Width = 1.5 Then
myCol.SetWidth InchesToPoints(1), wdAdjustNone
End If
Next i
'_______________________________________

to check for column width... but I do not now if it will work because I have
never seen "zero width" columns, and I could not create one either! I tried
setting colum width and cell width to 0, cell margins to 0, font to 1, all
paragraph settings to 0... and when I ran the code I always got a column
width of 1.5 points, or 0.02 inches.
I tried setting to colum width to 0 with a little macro, but whenever I used
the SetWidth method with a 0 value, Word changed the target column width to
fill out the available space. Then I found out I could not use any value
between 0.1 and 0.576 point... I then got a "value outside limits" error
message. Finally, any value between 0.576 and 1.5 generated a column width
of 1.5 points. It seems that 1.5 points is the lowest accepatable value for
column width... So I do not understand how you got "zero width" column... or
I totally did not understand your situation!

HTH
Cheers!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top