Viewing 1 post (of 1 total)
  • Author
    Posts
  • #6315
    Stefan
    Participant

    Show list of bookmarks in document (VBScript)
    Provided “as is”. No guaranty.
    Test first on non important documents! I am no programmer.
    Please comment below how it works.

    I have missed this feature under “Edit > Bookmarks”
    and ‘cus i want to play with macro language
    i decide to make this macro.
    (I think such an option should be there in that menu?)

    See EmEditor Help for how to use macros. Here’s an short help:
    1.) Save the code between 8< and >8 -lines as text file “somename.vbee” in EmEditor folder
    2.) use Menu “Macros > Select…” and choose this somename.vbee as current default macro
    3.) open an test file (try first on an test document!)
    and create some bookmarks with Strg+F2
    4.) press F4
    5.) you are prompted with an list of all bookmarks and the line contend at bookmarked line
    Your done.

    ———–8<---------------8<-----------


    #title = Bookmark List
    #tooltip = Show list of bookmarks in document
    '//
    '//
    '------------------------------------------------------Prepare work
    Set WshShell = CreateObject( "WScript.Shell" )
    maxCount = 50 'how many output lines to Display due window hight
    StartLine = document.selection.GetActivePointY (eePosView) 'get and store start parameters
    StartColumn = document.selection.GetActivePointx (eePosView)
    document.selection.SetActivePoint eePosView, 1, 1 'go to top of file
    '------------------------------------------------------Work

    Do
    FindNextBookmark = document.selection.NextBookmark
    If FindNextBookmark = TRUE THEN
    Count = Count + 1
    NextBookmark = document.selection.GetActivePointY (eePosView) 'get line number and contend
    str = document.GetLine (NextBookmark)
    If Count < maxCount +1 THEN 'collect all info for output
    BookmarkCollect = BookmarkCollect & vbCRLF & Count& " Line " & NextBookmark & ": " & vbTab & str
    End IF
    End IF
    LOOP UNTIL (FindNextBookmark = FALSE)
    document.selection.SetActivePoint eePosView, StartColumn, StartLine 'go back to start line
    '------------------------------------------------------Prepare output
    If Count > maxCount THEN
    result = maxCount
    resText = result & " of " & Count & " bokmarks listed only, due settings in script because of hight of this dialog."
    ELSE
    result = Count
    resText = "All " & Count & " bokmarks listed."
    End IF
    InfoText = "Use 'Strg+G' to jump to line."
    '------------------------------------------------------Output Messagebox. Use Strg+G to go to line
    If Count > 0 THEN
    n = WshShell.Popup( BookmarkCollect & vbCRLF & vbCRLF & resText & vbCRLF & InfoText, , "List of bookmarks", 0 )
    ELSE
    n = WshShell.Popup( "No bookmarks found in this document.", , "List of bookmarks", 0 )
    End IF


    ———–>8—————>8———–

    Settings:
    see “maxCount = 50 ”
    Default it will show the first 50 bookmarks only.
    Set it to your need.
    Test if the hight of the dialog box fit to your screen.

    Enjoy
    Stefan

    Comments and improvement suggestion welcome.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.