I was really trying to do this myself, but alas I got stuck.
I want to insert a bookmark at the present location with the name of the selected text.
so we have selText=selection.text
But of course, we cannot have any spaces in a BM name. I also need the current page number as part of the BM name
so we have selText=selection.text
So we need to turn "my selected text" into "01_my_selected_text"
The rest I think I can handle.
Thank you and have a good day!
Susan Flamingo
Update Edit:
Update Edit:
I was able to do this (hurray for me!!
Dim SelectedText As String
Dim BMN As String
Dim pgNo As Integer
Dim newPN As String
SelectedText = Selection.Text
pgNo = Selection.Range.Information(wdActiveEndPageNumber)
newPN = CStr(pgNo)
BMN = Replace(SelectedText, " ", "_")
'BMN = newPN & "_" & BMN
With ActiveDocument.Bookmarks
.Add Range:=Selection.Range, Name:="pg" & newPN & "_" & BMN
End With
Is this high quality code?