สวัสดี laxerlager,
ฉันมีปัญหาเดียวกัน / รำคาญ ดังนั้นแทนที่จะใช้ Kutools เพื่อสร้างบุ๊กมาร์ก ฉันใช้มาโครต่อไปนี้ มันคงจะทำให้ฉันมีความสุขมากถ้ามีใครอื่นได้รับประโยชน์จากงานของฉัน!
คุณรู้วิธีใช้มาโครหรือไม่?
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