Daiya said:
I don't know about doing it as a macro. The TOC is one field. I'm not sure
it has paragraphs, according to the object model, and if it did, I would
imagine you would somehow have to specify a paragraph within the field.
I agree - as per the object model, it doesn't appear to have paragraphs.
But you can select each "paragraph" individually via a macro (except
for the first one). With the cursor at the beginning of the entry,
"Selection.EndKey Unit:=wdLine, Extend:=wdExtend" will select the entire
paragraph (well, "line", technically; we tend to have one-line entries).
Unfortunately, if your cursor is at the beginning of the first entry,
this command selects the entire TOC.
I'm not sure why you need the TOC bookmarks in an array? If the TOC is
built from heading styles, they will automatically be listed in the
hyperlink to doc location dialog.
An array was just the way I decided to store them for future use by the
macro. I loop through the document, pulling in any bookmarks that begin
with "_toc". That way, they're in the order that I need to apply them
to the TOC entries. That part is working well, but I'm certainly open
to suggestions for a better way. I don't think I'm quite following your
comment about the dialog. Is there some way to figure out the bookmark
that the hyperlinked page number is referring to, so that it could then
be applied to the entire entry?
Me, I would probably go the approach of trying to format the page numbers so
that they look like links and visually remind the users they have to click
there.
That sure would be easier, but all of our clients use PCs, so they're
used to their internal documents having the entire entry hyperlinked,
and ask us to do the same.
Thanks,
Kristina