Hi Judy
JAS said:
is it possible to move hidden bookmarks to the end of the paragraph?
I work with special tools for translators, where Word documents are imported
and formatting/bookmarks etc are shown as codes. In quite a few cases hidden
bookmarks create so many codes inside single words, that I would prefer to
the bookmark either at the end of the paragraph or at least at the end of
the word.
The problem with doing this is that the hidden bookmarks are inserted by
Word for a reason, so it would be a bad idea to move them.
However, quite often bookmarks are left behind even when no longer needed,
so it is probably safe to remove some of them. The trick is knowing which
ones can be removed.
The most common cause of hidden bookmarks being inserted in a document is
rebuilding the table of contents. When that is done, a new bookmark is put
down on every heading, and no attempt is made to re-use the older one. So
the hidden bookmarks that have names beginnign with _Toc can all be deleted,
provided that you rebuild the ToC once more immediately afterwards. This
might cut down the number of bookmarks present by a surprising amount. The
following code does the needful, and displays its progress on the status bar
of the document window
Sub RebuildToC()
Dim i As Long
Dim j As Long
Dim k As Long
ActiveDocument.Bookmarks.ShowHidden = True
For i = ActiveDocument.Bookmarks.Count To 1 Step -1
j = j + 1
If LCase$(Left$(ActiveDocument.Bookmarks(i).Name, 4)) = "_toc" Then
ActiveDocument.Bookmarks(i).Delete
k = k + 1
End If
Application.StatusBar = j & " bookmarks checked, " & k & " bookmarks
deleted."
Next i
ActiveDocument.TablesOfContents(1).Update
End Sub