Reputation: 21695
The following line of code will insert text into a bookmark range in a word document.
objDoc.Bookmarks("DonorAddress").Range.Text = "6200 Main St."
How do I remove the entire line containing the address bookmark if I don't have any address data?
Upvotes: 1
Views: 18184
Reputation: 1410
If 'deleting the line' means deleting just one line of a paragraph, the following is the way:
objDoc.Bookmarks("DonorAddress").Range.Paragraphs(1).Range.Select
Selection.HomeKey wdLine
Selection.EndKey wdLine, wdExtend
Selection.Delete
Upvotes: 3
Reputation: 19077
By 'deleting the line' I believe you mean to 'delete paragraph'. If so you could do it in this way:
'2 steps to delete- rather not recommended
objDoc.Bookmarks("DonorAddress").Range.Paragraphs(1).Range.Select
Selection.Delete
or in one step:
objDoc.Bookmarks("DonorAddress").Range.Paragraphs(1).Range.Delete
Upvotes: 2