PDA

View Full Version : Changing the Text Wrapping Property of Word Tables



Dr@gonfly
10-10-2008, 12:19 PM
I've read through a lot of information about the text within a table wrapping but I am trying to modify the item you change on a table by going to Table/TableProperties. It's at the very bottom and you can choose None or Around. I have a document with tables in the footers which are set to Around and I would like them to be all None. Unfortunately, working with unlinked footers has become an occupational bullet point for me. here's what I am working with:

Sub ChangeWrapText ()
Dim oTable as Table
Dim oSection as Section
Dim oFooter as HeaderFooter
For each oSection In ActiveDocument.Sections
For each oFooter In oSection.Footers
oTable.rows.wraparoundtext=False
Next oFooter
Next oSection
End Sub

But it's saying Run-time error '91': Object variable or With block variable not set? I've tried putting in a With statement but the same error occurs, I don't get it... Does someone see something I don't?

When I use the macro recorder in the main story of the word document and record the action I am trying to replicate it gives me:

Selection.Tables (1).Rows.Wraparoundtext = false

Thank you!

Tommy
10-10-2008, 01:08 PM
I have not tested this so..... But I believe that you are not picking up the tables. You seem to be working only on the footer/header.

Sub ChangeWrapText()
Dim oTable As Table
Dim oSection As Section
Dim oFooter As HeaderFooter
For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
For Each oTable In oFooter 'added
oTable.Rows.WrapAroundText = False
Next oTable 'added
Next oFooter
Next oSection
End Sub

fumei
10-15-2008, 11:32 AM
That should not work, as oTable is still not set as a valid object.

For Each oSection In ActiveDocument.Sections
For Each oFooter In oSection.Footers
For Each oTable In oFooter.Range.Tables()

Tommy
10-15-2008, 01:26 PM
Jerry,

<Sigh> Your're right of course. What I get for not testing it.