I have a large document, 106 pages, and each page contains a table with other tables nested inside. Basically they are too small. Some have a preferred width set of 15 cm which I want to be 17, others a preferred width of 14cm which I want to be 16, and future documents I have to work on will have some without the preferred with set at all. I thought it would be easy to create a macro that looped through all the tables in the document, test the value of preferred width and set it appropriately. I could then adjust it for every new document or table I had to work on. But I can't get it to work. I'm using Word 2000. So far the best I can do is:
[vba]Sub setTableWidth()
Dim aTable As Table
For Each aTable In ActiveDocument.Tables
If aTable.PreferredWidth = CentimetersToPoints(15) Then
aTable.Select aTable.PreferredWidthType = _
wdPreferredWidthPoints.aTable.PreferredWidth = CentimetersToPoints(17)
End If
Next aTable
End Sub[/vba]
I can't see why this doesn't work, and I'd be very grateful if someone can enlighten me. I'm sorry the code is jumbled in above. I can't for the life of me get it to lay out properly.
Edit Lucas: vba tags added.....when posting code...select the code and hit the vba button