Topic: Text insertion before a bookmark

In connection with report preparation there was a task a little to change the text of document Word, namely design of tables in the form of cross-references (that is when we set a name of the table by means of field SEQ. And then we refer to it by means of field REF.
According to rules Word if we called in SEQ "Table" so it and in cross-reference REF will be displayed. And according to GOST it is necessary to write in title "Table", and in the link "Tab." As the report on some thousand pages is already prepared by rules which offers WORD, before me there is a task to correct all in accordance with GOST without breaking referential integrity.
The most simple variant - to replace a field ref with a hyperlink does not approach, as at the further editions of the table can be added, deleted, pass in other sections, important save automation of signatures at this stage.
Began to understand as the mechanism works. It appeared that at signing of a name of the table the bookmark is automatically added, range which contains a word "Table" and field SEQ - table number, and field Ref shows the text from range bookmarks on which it refers.
There was a natural idea: to alter at all titles of tables in bookmarks "Table" on "Tab.", to make the text hidden and to add before a bookmark a word "Table" already normal font.
Here also rummaged: as fought, it is impossible to interpose the text BEFORE a bookmark, it all time strives to get in a bookmark. At attempt to change range bookmarks the bookmark is deleted. Tried and manually, from Word and from vba using about what construction: activedocument.bookmarks ("_ref....").range.insertbefore ("table") - the text is interposed not before a bookmark, and inside.
Just in case I remind that the bookmark begins with the paragraph beginning, it is possible important.
So attention a question: prompt. Please. How correctly to interpose the text before a bookmark that in range bookmarks it did not get?


Re: Text insertion before a bookmark

It is possible to replace the previous character with it + "table". However, if the bookmark goes right after tables, i.e. before it there is no normal paragraph does not work.

Sub Makros1 ()
Dim r As Range, b As Bookmark, n&
For Each b In ActiveDocument. Bookmarks
n = b. Range. Start
Set r = ActiveDocument. Range (n - 1, n)
If Not r. Find. Execute ("(?)", True, True, wdFindStop, False, "\1tablitsa", wdReplaceOne) Then
Stop ' actions if changeover is not went right
End If
End Sub


Re: Text insertion before a bookmark

About, yes!!!!
It it!!!!
The subject is closed.