Undefined bookmark when form is protected

J

John

I would appreciate your help. I have a final bill that has mail merge fields,
form dropdown fields and calculations. When I lock the form to access the
dropdown fields, I get a Undefined bookmark syntax error message. My final
bill initially asks you to enter two dollar amounts and assigns them to
estimate and ded. My balance due subtracts these two amounts. When I protect
the form to access the dropdown boxes, I receive the message "undefined
bookmark ! estimate". I am not sure how to change to form to continue the
subtraction after the form is locked.

I would greatly appreciate any help. Thank you in advance.
 
D

Doug Robbins - Word MVP

What is the purpose of the mailmerge fields? They are pretty much
incompatible with a protected document.

When you say the bill asks you to enter some amounts, exactly how is this
request being made. In short, what sort for form is it?

See
Please Fill Out This Form
Part 1: Create professional looking forms in Word
http://www.computorcompanion.com/LPMArticle.asp?ID=22

Part 2: Adding Automation to your Word forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=46

Part 3: Learn more VBA (macros) to automate your forms.
http://www.computorcompanion.com/LPMArticle.asp?ID=119

Part 4: Use custom dialog boxes in your Word forms
http://www.computorcompanion.com/LPMArticle.asp?ID=127

Part 5: Connect your AutoForm to a database to save input time and keep
better records!
http://www.computorcompanion.com/LPMArticle.asp?ID=136


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

John

Doug,

Thank you for your help. The bill uses a mail merge with an automobile
damage estimating system to get the vehicle owner's information, vin, vehicle
year, make mdodel, etc. It then asks you (using the "ask" and "REF"
statements to gain the repair total, deductibles, etc. to fill in the final
bill portion of the form. It then utilizes dropdown boxes to select the area
that the damage was located. The only time the form is protected is when you
need to access the dropdown boxes. I am trying to alter the way that the form
is designed but have to keep this form running until my re-designed form is
ready.
 
D

Doug Robbins - Word MVP

The execution of the mailmerge will destroy the bookmarks in the document as
NORMALLY, the merge results in multiple replicas of the document being
created which means multiple instance of a the bookmark, but as each
bookmark must have a unique name, the bookmarks are omitted from the
document created by executing the mailmerge.

You may be able to use the following, but I would suggest a complete
re-design of the system

' Throwaway Macro created by Doug Robbins to "preserve" bookmarks during a
MailMerge
'
Dim abm As Bookmark, bmrange As Range, i As Long, Result As Document, j As
Long, k As Long, linkrange As Range, linktarget As String
Dim Source As Document
Set Source = ActiveDocument
i = 1
For j = 1 To Source.MailMerge.DataSource.RecordCount
For Each abm In ActiveDocument.Range.Bookmarks
System.PrivateProfileString("c:\bookmarks.txt", "bookmarkNames",
"bookmark" & i) = abm.Name & Format(j)
i = i + 1
Next
Next j
For Each abm In ActiveDocument.Range.Bookmarks
abm.Range.InsertBefore "#"
abm.Range.InsertAfter "#"
Next
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.Execute
End With
Set Result = ActiveDocument
k = 1
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="#*#", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Set bmrange = Selection.Range
bmrange.Characters(bmrange.Characters.Count).Delete
bmrange.Characters(1).Delete
Result.Bookmarks.Add System.PrivateProfileString("c:\bookmarks.txt",
"bookmarkNames", "bookmark" & k), bmrange
k = k + 1
Loop
End With
For i = 1 To Result.Hyperlinks.Count
linktarget = Result.Hyperlinks(i).SubAddress
Set linkrange = Result.Hyperlinks(i).Range
linkrange.Select
linktarget = linktarget &
Format(Selection.Information(wdActiveEndSectionNumber))
Result.Hyperlinks.Add Result.Hyperlinks(i).Range, "", linktarget
Next i

Source.Activate
Selection.HomeKey wdStory
Selection.Find.ClearFormatting
With Selection.Find
Do While .Execute(FindText:="#*#", MatchWildcards:=True,
Wrap:=wdFindContinue, Forward:=True) = True
Set bmrange = Selection.Range
bmrange.Characters(bmrange.Characters.Count).Delete
bmrange.Characters(1).Delete
Loop
End With

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top