×

normalInsert Bookmarks Feature

More
1 month 2 weeks ago #2668 by thelegend
Replied by thelegend on topic Insert Bookmarks Feature
You just need to add the proper reference. No need to understand exactly what it is, just do the following: 
  1. Go to the VBA editor (that is, press ALT+F11)
  2. Create an empty userform (see screenshot attached. You right click in the left pane, select insert, then Userform.) 
  3. Click on Tools on the menu bar
  4. Click on References
  5. Scroll down to Microsoft Forms 2.0 Object Library
  6. Make sure the box is checked
  7. Click OK
Try the macro again.
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #2667 by thelegend
Replied by thelegend on topic Insert Bookmarks Feature
Oh wow, all those letters and digits aren't supposed to be there. Let's try putting that screenshot again.
Attachments:

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #2665 by laxerlager
Replied by laxerlager on topic Insert Bookmarks Feature
forgot to mention that I also sometimes get the error "Compile error: User-defined type not defined"

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #2664 by laxerlager
Replied by laxerlager on topic Insert Bookmarks Feature
Hey there.

Thought I would never get a reply, let alone one with a Macro! Thanks so much.

Unfortunately, the Macro does not work for me. When selecting text and running the macro, I keep getting a VBA Error "Can't execute code in break mode".

Any thoughts or corrections?

Thanks again!

Please Log in or Create an account to join the conversation.

More
1 month 2 weeks ago #2663 by thelegend
Replied by thelegend on topic Insert Bookmarks Feature
Hello laxerlager,
I have the same problem/annoyance. So instead of using Kutools to create the bookmark, I use the following macro. It would make me very happy if someone else than could benefit from my work! 
You know how to use macros?
Sub InsertNewBookmark()
    Dim MyData As DataObject
    Dim strClip As String
    Dim bkName As String
    
    If Selection.Type = wdSelectionNormal Then
     Selection.Copy
    End If
    Set MyData = New DataObject
    MyData.GetFromClipboard
    strClip = MyData.GetText
    strClip = Trim(strClip)
    strClip = Replace(strClip, "   ", " ")
    strClip = Replace(strClip, "  ", " ")
    strClip = Replace(strClip, " ", "_")
    bkName = InputBox("Insert new bookmark name.", "Hello there.", strClip)
 
    On Error GoTo Oops
If (StrPtr(bkName) = 0) Then
'    MsgBox "You pressed cancel or [X]."
    Exit Sub
       
ElseIf (bkName = "") Then
    MsgBox "You have to name the bookmark. Try again."
    Call InsertNewBookmark
    
Else
     ActiveDocument.Bookmarks.Add _
     Name:=bkName, Range:=Selection.Range
    Exit Sub
End If
Oops:
    MsgBox ("The bookmark could not be created. Remember to follow these guidelines :" & vbNewLine & vbNewLine & "• Names must begin with a letter of the alphabet." _
    & vbNewLine & "• Names can contain only letters, numbers, and the underscore." & vbNewLine & "• Names cannot contain spaces or punctuation marks." & vbNewLine _
    & vbNewLine & "Let's try it again. Ready?")
    Call InsertNewBookmark
    
End Sub
The following user(s) said Thank You: Excelfans

Please Log in or Create an account to join the conversation.

More
8 months 1 week ago #2064 by laxerlager
Insert Bookmarks Feature was created by laxerlager
Is there a particular reason why spaces aren't automatically replaced with underscores when selecting text in a Word Document, and then clicking on the Insert Bookmark icon under the Kutools tab?  This seems like an entirely logical, time-saving feature that Kutools can, and should, implement promptly.  I would've expected such a feature when purchasing the software, and welcome any others' comments and/or thoughts on the same.

Attachments:

Please Log in or Create an account to join the conversation.

Moderators: jaychivoExcelfansqiuhongkun