Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Handy bookmark macro

    When designing a template that contains lots of bookmarks, it can be a bit of a pain sometimes to visualize which bookmark is which - you can see all the bookmarks but you can't see all their names.
    The Bookmark dialog is not very convenient in this regard.

    The following macro will type the name of each bookmark in a document, directly after each bookmark. This allows you to view onscreen or print out a "map" of where all the bookmarks are.

    This will work on bookmarks in the headers and footers as well as the body of the document.
    This is best run on a document based on the template, rather than on the template itself!

    Sub TypeEachBmkName()
    Dim aBmk As Bookmark
    Dim strBmkName As String
    For Each aBmk In ActiveDocument.Bookmarks
    strBmkName = aBmk.Name
    aBmk.Range.InsertAfter strBmkName
    Next aBmk
    End Sub

    Hope this is useful,
    Gary

  2. #2
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Hi Gary:

    You might be interested in an add-in from primeconsulting.com called Bookmark Popup (MSOUVP).dot. It places a menu on your toolbar which lists all your bookmarks by name, refreshes itself, & allows you to toggle "show bookmarks" on & off. I don't have the exact link but I know it was from their website.
    Attached Images Attached Images

  3. #3
    New Lounger
    Join Date
    Dec 2000
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Hi Gary,

    I've had some similar code - I put the bookmark name in as hidden text, then I can use a "HideBookmarks" routine that can search for it and remove it.

    It only works with bookmarks that are single points, not ones that cover a selection, or range of text - maybe I should modify it.

    Here are my 2 procedures, anyway - might be of use.

    '------------------------------------------- ShowBookmarks ---------------
    '
    Public Sub ShowBookmarks()
    '
    ' For each bookmark in the document, add the bookmark name, surrounded by
    ' square brackets, in hidden text
    ' See also - HideBookmarks()
    '

    Dim bkm As Object
    Dim bkname As String
    Dim bkc As Integer

    Selection.HomeKey Unit:=wdStory, Extend:=wdMove
    bkc = ActiveDocument.Bookmarks.Count

    For Each bkm In ActiveDocument.Bookmarks
    bkname = bkm.Name
    bkm.Select
    Selection.Font.Hidden = True
    Selection.TypeText Text:="[" & bkname & "]"
    Selection.Font.Hidden = False
    Next bkm
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    ActiveWindow.ActivePane.View.Type = wdPageView
    Else
    ActiveWindow.View.Type = wdPageView
    End If

    End Sub

    '---------------- start - cut here - HideBookmarks ---------------
    '
    Public Sub HideBookmarks()
    '
    ' For each bookmark in the document, remove the bookmark name in hidden text.
    ' See also - ShowBookmarks()
    '
    Dim bkm As Object
    Dim bkname As String
    Dim bkc As Integer

    Selection.HomeKey Unit:=wdStory, Extend:=wdMove
    bkc = ActiveDocument.Bookmarks.Count

    For Each bkm In ActiveDocument.Bookmarks
    bkm.Select
    bkname = bkm.Name
    Selection.Find.ClearFormatting
    Selection.Find.Font.Hidden = True
    With Selection.Find
    .Text = "[" & bkname & "]"
    .Forward = True
    .Format = True
    End With
    Selection.Find.Execute
    Selection.Cut
    Next bkm
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    ActiveWindow.ActivePane.View.Type = wdPageView
    Else
    ActiveWindow.View.Type = wdPageView
    End If

    End Sub

    ' --------------------------------- end - cut here

  4. #4
    New Lounger
    Join Date
    Dec 2000
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Hi Gary,

    I've had some similar code - I put the bookmark name in as hidden text, then I can use a "HideBookmarks" routine that can search for it and remove it.

    It only works with bookmarks that are single points, not ones that cover a selection, or range of text - maybe I should modify it.

    Here are my 2 procedures, anyway - might be of use.

    '-------------start - cut here - ShowBookmarks ------------
    '
    Public Sub ShowBookmarks()
    '
    ' For each bookmark in the document, add the bookmark name, surrounded by
    ' square brackets, in hidden text
    ' See also - HideBookmarks()
    '

    Dim bkm As Object
    Dim bkname As String
    Dim bkc As Integer

    Selection.HomeKey Unit:=wdStory, Extend:=wdMove
    bkc = ActiveDocument.Bookmarks.Count

    For Each bkm In ActiveDocument.Bookmarks
    bkname = bkm.Name
    bkm.Select
    Selection.Font.Hidden = True
    Selection.TypeText Text:="[" & bkname & "]"
    Selection.Font.Hidden = False
    Next bkm
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    ActiveWindow.ActivePane.View.Type = wdPageView
    Else
    ActiveWindow.View.Type = wdPageView
    End If

    End Sub

    '---------------- HideBookmarks ---------------
    '
    Public Sub HideBookmarks()
    '
    ' For each bookmark in the document, remove the bookmark name in hidden text.
    ' See also - ShowBookmarks()
    '
    Dim bkm As Object
    Dim bkname As String
    Dim bkc As Integer

    Selection.HomeKey Unit:=wdStory, Extend:=wdMove
    bkc = ActiveDocument.Bookmarks.Count

    For Each bkm In ActiveDocument.Bookmarks
    bkm.Select
    bkname = bkm.Name
    Selection.Find.ClearFormatting
    Selection.Find.Font.Hidden = True
    With Selection.Find
    .Text = "[" & bkname & "]"
    .Forward = True
    .Format = True
    End With
    Selection.Find.Execute
    Selection.Cut
    Next bkm
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
    ActiveWindow.ActivePane.View.Type = wdPageView
    Else
    ActiveWindow.View.Type = wdPageView
    End If

    End Sub

    ' --------------------------------- end - cut here

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Handy bookmark macro

    Hi Margaret,

    Thanks for sharing these - these look useful too.

    A couple of suggestions:
    To be able to use this for both types of bookmarks, a couple of things to try (sorry don't have time to test today :-)
    "bkm.Select
    Selection.Collapse wdCollapseEnd"

    or alternatively try playing around with:
    bkm.Range.InsertAfter

    The other suggestion is to declare the bookmark variable as a bookmark:
    Dim bkm As Bookmark
    rather than as an Object - the code should run faster.

    Regards,
    Gary

  6. #6
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Bookmarks? Sure!

    Let me know if you see anything you like.

    These are from my "Under The Hood" template which is on my web site. No source code there, though. If you want to see the source code I'll present it here.


    Public Function BookMarkSnagger(tbl As Table)
    ' Procedure : BookMarkSnagger
    ' Description: Generate a bookmark (from BOLDed text) for the current table.

    Sub cmd_ClearApplicationBookmarks()
    ' Procedure : cmd_ClearApplicationBookmarks
    ' Description: Clear all bookmarks which are prefixed with the application identifier.


    Public Sub cmd_MarkUnBookmarkedText()
    ' Procedure : cmd_MarkUnBookmarkedText
    ' Description: Mark un-bookmarked text with a character style.


    Public Sub cmd_SelectDownNextUnBookMarkedText()
    ' Procedure : cmd_SelectDownNextUnBookMarkedText
    ' Description: Highlight the next chunk of text that is not bookmarked.


    Public Sub cmd_SelectUpNextUnBookMarkedText()
    ' Procedure : cmd_SelectUpNextUnBookMarkedText
    ' Description: Highlight the next chunk of text that is not bookmarked.

    Public Sub cmd_BookMarkDocumentor()
    ' Procedure : cmd_BookMarkDocumentor
    ' Description: Generate a new document with a catalogue of bookmarks from the current document.



    Public Sub cmd_BookMarkSnagAllTables()
    ' Procedure : BookMarkSnagAllTables
    ' Description: Generate a bookmark (from BOLDed text) for all tables in a document.

    Public Sub cmd_VisitBookmarks()
    ' Procedure : VisitBookmarks
    ' Description: Visit each bookmark in the active document until the user decides to stop.


    Sub cmd_BookmarksFromHeadings()
    ' apply this to a course document, then use Customizer


    Function BkMkRanges(lngAr() As String, lngToDo() As String)
    ' Mark all text that is *not* bookmarked


    Function DumpBookmarkArray(strCurrentDoc As String, strDoc As String, strAr() As String)


    Function lngBuildBookmarkArray(strDoc As String, strAr() As String) As Long


    Function strAddBookmark(rng As Range, intLevel As Integer, IntLengthText As Integer) As String
    ' Procedure : strAddBookmark
    ' Description: Add a bookmark with a generated identifier.

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Handy bookmark macro

    Hi Chris,

    "see anything you like" - you've got to be kidding![img]/w3timages/icons/grin.gif[/img] - this looks like a little treasure box of bookmarks code - I don't see anything I don't like!

    Now, how does this work, do I select one from column A and one from column B? - or do I get three wishes (gotta think hard)[img]/w3timages/icons/laugh.gif[/img]

    Gary

  8. #8
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    I'm still not understanding the new lounge. When I want to reply, I don't see the button, and when I *do* see the button, there's no quoted text. Ah me!

    maybe I should just dump the bookmark library one by one. let me take a look and see what low-level procedures it assumes. I started (last time) with the very low-level string functions because I use them *everywhere*.

  9. #9
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Thanks Gary - what a wonderful wee macro - something I wish I had years ago!

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Hi Chris:

    When you say you can't see the button, do you mean you have to scroll or it just doesn't show up? What browser are you using?

    And as far as the quote, there's a tag panel that has the quote button. And it shows up like this.

    <hr>I'm still not understanding the new lounge. When I want to reply, I don't see the button, and when I *do* see the
    button, there's no quoted text. Ah me!<hr>

  11. #11
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Phil, thanks for the reply.

    I see the reply button (grey box with curved arrow) in your post. Not a problem.

    In some modes, that button doesn't appear at all, no matter where I scroll on the current screen.



    What did you mean by "tag panel"? I've explored the three Profile screens and the FAQs and the Help item on the menu. I see nothing that even HINTS at a reply character (I'm thinking of the greater-than symbol for the LHS of each quoted line.

    I note that when i chose the Reply button just now, no text got quoted at all; I'm trying to remember to select, Edit Copy and Edit Paste when replying to messages.

  12. #12
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    It keeps changing. When you get to the reply screen (has nothing to do with profiles), just above it on the right should be blue type that says "Show 1 - Click TagPanel". It's a link & a panel opens with "emoticons" & tags to make text <font face="Snap ITC">different</font face=snap>, <big>big</big>, small, etc. It also allows you to post links such as yours
    <A target="_blank" HREF=http://www.vif.com/users/cgreaves/download.html>http://www.vif.com/users/cgreaves/download.html</A>

    You can also type the tags such as
    {url}link goes here{/url}, except use brackets instead of braces. It takes a little while. All in all, this lounge is really great--you can attach small files, pictures. Eileen has done an amazing job.

  13. #13
    Platinum Lounger
    Join Date
    Dec 2000
    Location
    Queanbeyan, New South Wales, Australia
    Posts
    3,730
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Chris,

    This certainly looks like a treasure trove. You're showing just by the routine names that you've spent a lot of time and effort learning about what developers require, and how to make thrir job easier.

    Looking forward to the contributions of code as they come in!
    Subway Belconnen- home of the Signboard to make you smile. Get (almost) daily updates- follow SubwayBelconnen on Twitter.

  14. #14
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    replied in "Lounge Matters"

  15. #15
    5 Star Lounger
    Join Date
    Dec 2000
    Location
    Tallahassee, Florida, USA
    Posts
    901
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Handy bookmark macro

    Um... nothing like showing my ignorance. Can I have the macro apply highlighting to the BM? That way there's no ambiguity as to what is or isn't part of the original mark. Thanks!

    Edited by KB MacKenzie
    I got it -- sort of, but it highlights the name as well... not a bad thing, just wasn't expected:

    aBmk.Select
    Selection.Range.HighlightColorIndex = wdYellow
    Karen

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •