Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
It will be useful to be able to create an index of all the bookmark names
with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/office/comm...ocmanagemen t |
#2
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
NJK wrote:
It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6.5), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab & _ bk.Range.Information(wdActiveEndAdjustedPageNumber ) _ & vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#3
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Jay Freedman wrote:
NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#4
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Hello Jay.
A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#5
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
To show the text of the bookmark, replace the line
rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#6
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Jay, thanks for text replacement.
Sorry about the "ned" - podgy-finger-syndrome this morning. To clarify: my second request is not for an Index so I don't want the macro to jump to the END of the document, but to display where the cursor happens to be. As I want a list of the bookmarks, I wont need the page numbers and leaders, etc. But I would like the list still to be hyperlinked. Sorry for the confusion. Many thanks again. DeanH "Jay Freedman" wrote: To show the text of the bookmark, replace the line rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#7
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Ah, OK.
As MVP Greg Maxey pointed out to me in an email, this is one situation where it's easier to use the Selection instead of a Range object. That way you don't have to keep collapsing after every insertion. I think this is what you're looking for: Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Hyperlinks.Add _ Anchor:=.Range, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Text .TypeParagraph Next End With End Sub DeanH wrote: Jay, thanks for text replacement. Sorry about the "ned" - podgy-finger-syndrome this morning. To clarify: my second request is not for an Index so I don't want the macro to jump to the END of the document, but to display where the cursor happens to be. As I want a list of the bookmarks, I wont need the page numbers and leaders, etc. But I would like the list still to be hyperlinked. Sorry for the confusion. Many thanks again. DeanH "Jay Freedman" wrote: To show the text of the bookmark, replace the line rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#8
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Fantastic, Jay.
Does exactly as required and will save me so much time. All the best DeanH "Jay Freedman" wrote: Ah, OK. As MVP Greg Maxey pointed out to me in an email, this is one situation where it's easier to use the Selection instead of a Range object. That way you don't have to keep collapsing after every insertion. I think this is what you're looking for: Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Hyperlinks.Add _ Anchor:=.Range, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Text .TypeParagraph Next End With End Sub DeanH wrote: Jay, thanks for text replacement. Sorry about the "ned" - podgy-finger-syndrome this morning. To clarify: my second request is not for an Index so I don't want the macro to jump to the END of the document, but to display where the cursor happens to be. As I want a list of the bookmarks, I wont need the page numbers and leaders, etc. But I would like the list still to be hyperlinked. Sorry for the confusion. Many thanks again. DeanH "Jay Freedman" wrote: To show the text of the bookmark, replace the line rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#9
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Jay, I have been using this macro for sometime now and have one change but
cannot get find the right commands. When the macro is run, the list of bookmarks is displayed perfectly but their coding is for a hyperlink (as per line "ActiveDocument.Hyperlinks.Add _") how can this be changed to show the cross-reference "Ref" instead. For example the code for a bookmark looks like this: { HYPERLINK "DocName.doc" \l "bk001" } but would like instead: { REF bk001 \h } Many thanks again. DeanH "DeanH" wrote: Fantastic, Jay. Does exactly as required and will save me so much time. All the best DeanH "Jay Freedman" wrote: Ah, OK. As MVP Greg Maxey pointed out to me in an email, this is one situation where it's easier to use the Selection instead of a Range object. That way you don't have to keep collapsing after every insertion. I think this is what you're looking for: Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Hyperlinks.Add _ Anchor:=.Range, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Text .TypeParagraph Next End With End Sub DeanH wrote: Jay, thanks for text replacement. Sorry about the "ned" - podgy-finger-syndrome this morning. To clarify: my second request is not for an Index so I don't want the macro to jump to the END of the document, but to display where the cursor happens to be. As I want a list of the bookmarks, I wont need the page numbers and leaders, etc. But I would like the list still to be hyperlinked. Sorry for the confusion. Many thanks again. DeanH "Jay Freedman" wrote: To show the text of the bookmark, replace the line rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#10
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Hi Dean,
It's only a small change. The arguments of the ActiveDocument.Fields.Add command are fairly similar to those of the ActiveDocument.Hyperlinks.Add command. Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Fields.Add _ Range:=.Range, _ Type:=wdFieldRef, _ Text:=bk.Name & " \h", _ PreserveFormatting:=False .TypeParagraph Next End With End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. DeanH wrote: Jay, I have been using this macro for sometime now and have one change but cannot get find the right commands. When the macro is run, the list of bookmarks is displayed perfectly but their coding is for a hyperlink (as per line "ActiveDocument.Hyperlinks.Add _") how can this be changed to show the cross-reference "Ref" instead. For example the code for a bookmark looks like this: { HYPERLINK "DocName.doc" \l "bk001" } but would like instead: { REF bk001 \h } Many thanks again. DeanH "DeanH" wrote: Fantastic, Jay. Does exactly as required and will save me so much time. All the best DeanH "Jay Freedman" wrote: Ah, OK. As MVP Greg Maxey pointed out to me in an email, this is one situation where it's easier to use the Selection instead of a Range object. That way you don't have to keep collapsing after every insertion. I think this is what you're looking for: Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Hyperlinks.Add _ Anchor:=.Range, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Text .TypeParagraph Next End With End Sub DeanH wrote: Jay, thanks for text replacement. Sorry about the "ned" - podgy-finger-syndrome this morning. To clarify: my second request is not for an Index so I don't want the macro to jump to the END of the document, but to display where the cursor happens to be. As I want a list of the bookmarks, I wont need the page numbers and leaders, etc. But I would like the list still to be hyperlinked. Sorry for the confusion. Many thanks again. DeanH "Jay Freedman" wrote: To show the text of the bookmark, replace the line rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#11
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Many thanks Jay.
I will give this a go next week when I am back in the office. Have a great weekend. Ciao DeanH "Jay Freedman" wrote: Hi Dean, It's only a small change. The arguments of the ActiveDocument.Fields.Add command are fairly similar to those of the ActiveDocument.Hyperlinks.Add command. Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Fields.Add _ Range:=.Range, _ Type:=wdFieldRef, _ Text:=bk.Name & " \h", _ PreserveFormatting:=False .TypeParagraph Next End With End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. DeanH wrote: Jay, I have been using this macro for sometime now and have one change but cannot get find the right commands. When the macro is run, the list of bookmarks is displayed perfectly but their coding is for a hyperlink (as per line "ActiveDocument.Hyperlinks.Add _") how can this be changed to show the cross-reference "Ref" instead. For example the code for a bookmark looks like this: { HYPERLINK "DocName.doc" \l "bk001" } but would like instead: { REF bk001 \h } Many thanks again. DeanH "DeanH" wrote: Fantastic, Jay. Does exactly as required and will save me so much time. All the best DeanH "Jay Freedman" wrote: Ah, OK. As MVP Greg Maxey pointed out to me in an email, this is one situation where it's easier to use the Selection instead of a Range object. That way you don't have to keep collapsing after every insertion. I think this is what you're looking for: Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Hyperlinks.Add _ Anchor:=.Range, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Text .TypeParagraph Next End With End Sub DeanH wrote: Jay, thanks for text replacement. Sorry about the "ned" - podgy-finger-syndrome this morning. To clarify: my second request is not for an Index so I don't want the macro to jump to the END of the document, but to display where the cursor happens to be. As I want a list of the bookmarks, I wont need the page numbers and leaders, etc. But I would like the list still to be hyperlinked. Sorry for the confusion. Many thanks again. DeanH "Jay Freedman" wrote: To show the text of the bookmark, replace the line rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#12
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
Jay, works beautifully, many thanks
All the best DeanH "DeanH" wrote: Many thanks Jay. I will give this a go next week when I am back in the office. Have a great weekend. Ciao DeanH "Jay Freedman" wrote: Hi Dean, It's only a small change. The arguments of the ActiveDocument.Fields.Add command are fairly similar to those of the ActiveDocument.Hyperlinks.Add command. Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Fields.Add _ Range:=.Range, _ Type:=wdFieldRef, _ Text:=bk.Name & " \h", _ PreserveFormatting:=False .TypeParagraph Next End With End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. DeanH wrote: Jay, I have been using this macro for sometime now and have one change but cannot get find the right commands. When the macro is run, the list of bookmarks is displayed perfectly but their coding is for a hyperlink (as per line "ActiveDocument.Hyperlinks.Add _") how can this be changed to show the cross-reference "Ref" instead. For example the code for a bookmark looks like this: { HYPERLINK "DocName.doc" \l "bk001" } but would like instead: { REF bk001 \h } Many thanks again. DeanH "DeanH" wrote: Fantastic, Jay. Does exactly as required and will save me so much time. All the best DeanH "Jay Freedman" wrote: Ah, OK. As MVP Greg Maxey pointed out to me in an email, this is one situation where it's easier to use the Selection instead of a Range object. That way you don't have to keep collapsing after every insertion. I think this is what you're looking for: Sub BookmarkIndex() Dim bk As Bookmark With Selection .TypeParagraph .Style = ActiveDocument.Styles("Index Heading") .TypeText "Bookmarks" & vbCr .Style = ActiveDocument.Styles("Index 1") For Each bk In ActiveDocument.Range.Bookmarks ActiveDocument.Hyperlinks.Add _ Anchor:=.Range, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Text .TypeParagraph Next End With End Sub DeanH wrote: Jay, thanks for text replacement. Sorry about the "ned" - podgy-finger-syndrome this morning. To clarify: my second request is not for an Index so I don't want the macro to jump to the END of the document, but to display where the cursor happens to be. As I want a list of the bookmarks, I wont need the page numbers and leaders, etc. But I would like the list still to be hyperlinked. Sorry for the confusion. Many thanks again. DeanH "Jay Freedman" wrote: To show the text of the bookmark, replace the line rg.Text = bk.Name & vbTab with rg.Text = bk.Range.Text & vbTab I don't understand your request to "not jump to the ned [I guess you meant 'end'] of the document but still be hyperlinked". Can you clarify? On Fri, 10 Jul 2009 00:07:01 -0700, DeanH wrote: Hello Jay. A nice little helpful macro, thanks. I have a slightly different requirement and have tried to edit this macro without success. I am after this Index to show the Bookmark Text (as in Cross reference, Insert reference to not the Bookmark Name, possible? Also, if this possible, how would the macro be to produce a list of these Bookmark Names without the page numbers, leaders, etc. and not jump to the ned of the document but still be hyperlinked? Many thanks for your assistance. DeanH "Jay Freedman" wrote: Jay Freedman wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): [snip] Sorry, the previous macro produced a plain-text index without any hyperlinks (which is all you would get from an ordinary index). This version hyperlinks the page numbers back to the bookmarks: Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab rg.Collapse wdCollapseEnd ActiveDocument.Hyperlinks.Add _ Anchor:=rg, _ Address:=ActiveDocument.Name, _ SubAddress:=bk.Name, _ TextToDisplay:=bk.Range.Information( _ wdActiveEndAdjustedPageNumber) Set rg = ActiveDocument.Range rg.Collapse wdCollapseEnd rg.InsertBefore vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#13
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
I'd like to be able to check my bookmark names but I don't understand
anything about entering the code you've written below. I'm totally lost when I look at gmayor.com! Is there a Word 2007 feature that would just show the name on the screen and when I print the document? "Jay Freedman" wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6.5), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab & _ bk.Range.Information(wdActiveEndAdjustedPageNumber ) _ & vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
#14
Posted to microsoft.public.word.docmanagement
|
|||
|
|||
INDEX of BOOKMARKS
If you go to Insert | Links | Bookmark, the dialog shows the existing
bookmarks. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "terryc" wrote in message ... I'd like to be able to check my bookmark names but I don't understand anything about entering the code you've written below. I'm totally lost when I look at gmayor.com! Is there a Word 2007 feature that would just show the name on the screen and when I print the document? "Jay Freedman" wrote: NJK wrote: It will be useful to be able to create an index of all the bookmark names with their page number and hyperlink to that bookmark. eg [BookmarkName]....[pageNumber] The use of this will be very helpfull when software requirement specifiers can have a list of all the bookmarks from another document instead of having both documents open. This will cut down in a lot of mouse moving. An index of bookmarks can be created with a reasonably simple macro (see http://www.gmayor.com/installing_macro.htm if needed): Sub BookmarkIndex() Dim bk As Bookmark Dim rg As Range Set rg = ActiveDocument.Range With rg .Collapse wdCollapseEnd .InsertBefore vbCr .Style = ActiveDocument.Styles("Index Heading") .Text = "Bookmarks" & vbCr .Collapse wdCollapseEnd .Style = ActiveDocument.Styles("Index 1") .ParagraphFormat.TabStops.Add _ Position:=InchesToPoints(6.5), _ Alignment:=wdAlignTabRight, _ Leader:=wdTabLeaderDots End With For Each bk In ActiveDocument.Range.Bookmarks rg.Text = bk.Name & vbTab & _ bk.Range.Information(wdActiveEndAdjustedPageNumber ) _ & vbCr rg.Collapse wdCollapseEnd Next End Sub -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Word 2007 bookmarks - How to display bookmarks on page? | Microsoft Word Help | |||
Index and bookmarks or hyperlinks | Microsoft Word Help | |||
Problem: Word Index Updates Delete all Bookmarks | Microsoft Word Help | |||
index entries as bookmarks? | Microsoft Word Help | |||
Concordance/Index File--Make Index Entries Case Insensitive | Microsoft Word Help |