PDA

View Full Version : Bookmark Name- Change content without change Bookmark name



Victor
08-27-2015, 01:59 PM
Hi all

INVOCEOC001 ----->content in word file

If I press f5(goto) PreOrder the OB is selected sincec I previously define OB as a Bookmark

Also if I press f5(goto) Order 001 is selected since I previously define 001 as a Bookmark

The catch :

I I need to change OB to OC I just delete “C” and write “V” (OV) then when press f5(goto) PreOrder the bookmark selected change from OB to only O.

My question is there any way that the bookmark do not change, since I used it in a code where PreOrder is defines as bookmark range OB and not only O, due to the change in the bookmark name.

Bookmark names use
Order for bookmark name range 001
PreOrder for bookmark name range OB

Enclosed Word file.

gmayor
08-27-2015, 09:03 PM
The problem in your document is that you have C001 as the bookmark Order and OC as the bookmark PreOrder. The bookmarks overlap. For the macro in the other thread to work correctly the Order bookmark should have the value here as '001', omitting the 'C' from the other bookmark. The macro also is looking for a bookmark called 'OB' as your previous instruction and not a bookmark called 'PreOrder'. If you want the bookmark name to be 'PreOrder' then you must change the name in the macro from 'OB' to 'PreOrder'.

For a better way of looking at your bookmarks and their contents (and editing them without screwing things up) see http://www.gmayor.com/BookmarkandVariableEditor.htm

Victor
08-28-2015, 06:07 AM
Hi Graham:

Lets forget the code for a second and do this manually.

Initially the Order bookmark name for PreOrder covers the the 2 digits letter "OB" of "InvoiceOB001" and "001 bookmark name for Order covers the 3 digits numbers "001".

Up to this there is no overlap.

Second:

Once I manually changed the letter form "B' to "C"" in the text "InvoiceOB001" to InvoiceOC001" what happened is that
the Preorder bookmark changes to only "O" and the Order bookmark changes from 001 to "C001"

See Show Word codes if file - File-Options-Advanced then selected Show Book Marks under Show Document Content heading

Also there is no overlap just a change of the area cover by the bookmarks.

Third Bookmark rules:



Add text between any two characters marked by a bookmark

The addition is included in the bookmark.



Position the insertion point directly before the text that is marked and then add to the item

The addition is included in the bookmark.



Position the insertion point directly after the ending bracket of a bookmark, and then add to the item

The addition is not included in the bookmark.





Sorry I am not as clear as I wish so you can help me.

Please help me to fixed it.

PS read the http://www.gmayor.com/BookmarkandVariableEditor.htm (http://www.gmayor.com/BookmarkandVariableEditor.htm) as suggested. Thanks

gmayor
08-28-2015, 09:34 PM
In the test document you supplied, the bookmarks overlap. Below is a screenshot of the bookmarks in that document.

14284
You need to start by re-applying the bookmarks as you think you have them.

14285
The add-in makes it very clear what the content of the bookmarks is, and easy to change it without displaying the bookmark boundaries.

Victor
08-29-2015, 03:19 AM
Hi Graham

See enclosed file (maybe the one I sent before do not show what I intent to explain)

INVOICEOB001



If I press f5(goto) PreOrder the OB is selected sincece I previously define OB as a Bookmark

Also if I press f5(goto) Order 001 is selected since I previously define 001 as a Bookmark

The catch :

I I need to change OB to OC I just delete “C” and write “V” then when press f5(goto) PreOrder the bookmark selected change from OB to only O.

My question is there any way that the bookmark do not change, no code used.

Thanks for your patience with me and the help provided.

gmayor
08-29-2015, 05:11 AM
Your example amply demonstrates the difficulty of manually editing bookmarks that are sited adjacent to one another. You cannot type between the final character and the bookmark boundary. You would have to re-apply the bookmarks after editing, and this is best done using a macro. The add-in I suggested makes the job child's play.

If you don't want to use the add-in, then take a look at the FillBM function which is listed at http://www.gmayor.com/useful_vba_functions.htm
You can call it to edit the bookmark e.g.

Sub Macro1()
FillBM "PreOrder", "OC"
End Sub

Victor
08-29-2015, 05:35 AM
Thanks fo all you help. With the information you provided I can now continue forward.

Until next time.