Problem with removing single rows from a Word table using Excel VBA

m_in_spain

Board Regular
Joined
Sep 28, 2018
Messages
72
Office Version
  1. 365
Platform
  1. Windows
The continuing saga of getting Excel to update my word document.

After seemingly endless attempts, lots of help from here, I have found the following line of code actually deletes a (bookmarked in Word with same name) row from my word table:

Code:
If docWord.Bookmarks.Exists(xlName.Name) Then docWord.Bookmarks(xlName.Name).Range.Rows.Delete

My problem is that it deletes not only the row i have bookmarked (Bookmark is at the first typing space in the row) but also other rows below it, sometimes 2, sometimes 3. In Word i shade fill some lines to denote a different area, the above code seems to delete all lines down to the shade change.

I have tried, what seems obvious to me, i.e. change Rows to Row, and also leaving out .Range, but each time it then doesn't delete anything.

I need each bookmark to delete one row in word only. Any help much appreciated
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Many thanks again. I have now split my table in word into lots of single lines, as even with the Rows (1) it still managed to delete some other rows, now they are all single row with 1 pt spacing between them it works like a dream thank you. Odd thing was before i split the rows, sometimes it deleted the row, sometimes more than one row and many times deleted nothing! Now it is solved tho, thanks again.
 
Upvote 0

Forum statistics

Threads
1,223,739
Messages
6,174,217
Members
452,551
Latest member
croud

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top