The Problem (Q-score 13, ranked #8th of 32 in the Word VBA archive)
The scenario as originally posted in 2015
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!
Why community consensus is tight on this one
Across 32 Word VBA entries in the archive, the accepted answer here holds solid answer (above median) status — meaning voters are unusually aligned on the right fix.
The Verified Solution — solid answer (above median) (+7)
6-line Word VBA pattern (copy-ready)
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
When to Use It — classic (2013–2016)
A top-10 Word VBA pattern — why it still holds up
Ranks #8th of 32 in the Word VBA archive. The only pattern ranked immediately above it is “SaveAs vs SaveAs2 in the Microsoft Office Word object model” — compare both if you’re choosing between approaches.
What changed between 2015 and 2026
The answer is 11 years old. The Word VBA object model has been stable across Office 2013, 2016, 2019, 2021, 365, and 2024/2026 LTSC, so the pattern still compiles. Changes that might affect you: 64-bit API declarations (use PtrSafe), blocked macros in downloaded files (Mark-of-the-Web), and the shift toward Office Scripts for web-first workflows.