Word VBA – Eliminate Floating Object Tables

calendar_today Asked Jul 7, 2015
thumb_up 7 upvotes
history Updated April 16, 2026

Question posted 2015 · +13 upvotes

I have a ton of Word documents with somewhat “corrupted” tables. I’ve been able to automate most of the repair process, but one issue is still beyond me.

Many of the tables are floating objects – when I show the hidden formatting marks, I see an anchor by the table. I can’t leave the documents like this, I need to make everything inline.

I do have a segment of code that “fixes” this, but I don’t think it is a good solution. By changing the text wrapping from “None” (the default – what I want it to be) to “Around” and back to “None”, this gets fixed. The code is,

Selection.Tables(1).Rows.WrapAroundText = True
Selection.Tables(1).Rows.WrapAroundText = False

I’m sure there is a better way to do this. Does anyone know of something that will work? Thanks!

Accepted answer +7 upvotes

I have no idea why flapping the WrapAroundText flag solves your problem, VBA has alot of quirks like that.

Automating this method to all of the tables in the document is fairly simple:

Dim i as Integer
For i=1 to Len(ActiveDocument.Tables)
  ActiveDocument.Tables(i).Rows.WrapAroundText = True
  ActiveDocument.Tables(i).Rows.WrapAroundText = False
Next i

Word VBA objects referenced (3)

  • ActiveDocument.Tables — PivotTable.ShowTableStyleLastColumn property (Excel)pivottable-showtablestylelastcolumn-property-excel-63370f64-5188-50fd-3e8a-6fdb0
  • ActiveDocument.Tables — Change tables involved in a one-to-many relationship in a DAO Recordset
  • Selection — Working with the Selection Object