Can a range cover non-adjacent paragraphs?

E

Ed from AZ

I have a report document with several Excel files in an appendix.
Each of these files has a bookmark to allow a hyperlink to the file to
be placed in the report.

A co-worker who also works with this report needs to see the bookmark
names so she knows exactly which file is attached where. So I was
going to iterate through the report with a macro that would extract
the bookmark name and place it next to the bookmark. Not a problem.

We do not, however, want to send out the report like that! So I had
the idea that if a Word range can cover non-adjacent paragraphs, I can
just add the range covered by the bookmark name to a bigger range,
which could then somehow be manipulated to allow a mass delete when
we're done with the report.

Can this be done? If not, how would y'all suggest I do this?

Ed
 
D

Doug Robbins - Word MVP

While a range can begin in one paragraph and end in a non-adjacent
paragraph, it will however include everything in between, which I would be
pretty sure means that the answer to what you were thinking of is "No".

However, if you can interate through the bookmarks to insert the names, why
can't you interated through them again to remove the name

An alternative might be to use code to put the bookmark name in a comment
and then use code to delete all of the comments

With ActiveDocument
For i = 1 to .Bookmarks.Count
.Comments.Add .Bookmarks(i).Range, .Bookmarks(i).Name
Next i
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
E

Ed from AZ

Much better idea, Doug! Thank you!!

Ed


While a range can begin in one paragraph and end in a non-adjacent
paragraph, it will however include everything in between, which I would be
pretty sure means that the answer to what you were thinking of is "No".

However, if you can interate through the bookmarks to insert the names, why
can't you interated through them again to remove the name

An alternative might be to use code to put the bookmark name in a comment
and then use code to delete all of the comments

With ActiveDocument
    For i = 1 to .Bookmarks.Count
        .Comments.Add .Bookmarks(i).Range, .Bookmarks(i).Name
    Next i
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP









- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top