Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word XP loosing bookmarks from documents

Status
Not open for further replies.

YACHTIE

Technical User
Feb 17, 2004
77
CA
Occasionally my Word document which contains some macros and formfields appears to loose a bookmark, which is the starting/trigger point in the protected document to add some rows to a table.
Of course when the bookmarks is not there the macro pukes.

Most of the time it works but then somehow it breaks??
The bookmark still shows in the properties of the formfield window, however not when you look at Insert/Bookmarks.

Any suggestions on how to prevent this from happening other than NOT using Word for this application?

Appreciate any suggestions.
TIA
 
hard say without u post code

if macro locate formfield AS BOOKMARK & copy, formfield name moves ( & shows Properties) but bookmark name lost as bookmark location (Long Integer) specific.

if using Range, could b simple - move Range.Start (or .End) + (or -) 1 to keep bookmark alive. Bmarks funny @ times.

 
Thanks for the response Phaed, like you said:
Bmarks funny @ times.
That may be the only explanation, because that's what I have become to believe, and I do not believe the code is what is causing the problem as it did occur with different code before as well.

Nevertheless here is the code in question
Code:
Sub NewPartRows()
'This macro adds a table row in a form field protected document
Dim r As Range
Application.ScreenUpdating = False
ActiveDocument.Unprotect Password:="MES3052D"
    Selection.GoTo What:=wdGoToBookmark, Name:="PartText39"
    Selection.Collapse Direction:=wdCollapseStart
        
' set range object as last row in table
' make the Selection the range end
Set r = ActiveDocument.Bookmarks("\table").Range. _
    Rows(ActiveDocument.Bookmarks("\table").Range.Rows.Count).Range
    Selection.Start = r.End
'  copy range and paste it
    r.Copy
    r.Paste
'  release range object
        Set r = Nothing
ActiveDocument.Protect (wdAllowOnlyFormFields), NoReset:=True, Password:="MES3052D"
Application.ScreenUpdating = True
End Sub
Now I should mention there is more code with the document, there is another module similar to the above and several Private macros under "This document".

Maybe you could elaborate on your:
move Range.Start (or .End) + (or -) 1 to keep bookmark alive.
???

thanks
 
code posted looks 4 bookmark in table, copies Range of row and add same.

works. bookmark still there. r u saying it sometimes keeps bookmark, sometimes not?

re: comment. when using range of bookmark, sometime using Range.MoveStart + 1 edges range just beyond the long integer location of range start, keeping bookmark integer location in place. code posted ok, bookmark still there.

looks like fumei code
 
Yeah You're right it fumei code, also right in that bookmark sometimes gets wiped out.

How do I modify this code with "Range.MoveStart+1" ??
As that sounds like maybe a solution.
TIA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top