View Single Post
  #12   Report Post  
Jay Freedman
 
Posts: n/a
Default

Hi Carol,

You're getting there... but you have to exactly match the names of the
bookmarks in the code. Since spaces aren't legal in bookmark names, I can
tell right away some of them are wrong. Look at the names in the list when
you bring up the Insert Bookmark dialog, and make the names in the code
*exactly* the same.

There's another complication with the way you userform is putting the text
in the document. When you use the .InsertBefore command, the text goes
*before* the bookmark, not *in* the bookmark. So when you do get the
userform to finish without errors, the Ref fields won't have anything to
show because the bookmarks themselves will be empty. The proper code for
this is shown he
http://word.mvps.org/FAQs/MacrosVBA/...AtBookmark.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

Carol wrote:
I started from scratch with the document. In the spots where I wanted
the different variables, I clicked on Insert | Bookmark and then
typed in the name and clicked on Add. Where a variable was used more
than once I clicked on Insert | Fields and Ref and clicked ont he
Bookmark that it pointed to. Then I went to the Visual Basic Editor
and inserted the User Form and added labels and textboxes for all of
the bookmarks. I then added a command button and named it ok. After
that I right-clicked on the command button and chose View Code. Once
there, in between "Private Sub CommandButton1_Click()" and "End Sub,"
I typed:

With ActiveDocument
.Bookmarks("Decedent").Range _
.InsertBefore TextBox1
.Bookmarks("Venue").Range _
.InsertBefore TextBox2
.Bookmarks("Estate Number").Range _
InsertBefore TextBox3
.Bookmarks("Personal Representative").Range _
.InsertBefore TextBox4
.Bookmarks(Date of Death").Range _
.InsertBefore TextBox5

End With
Userform1.Hide

Ok, then I used Alt+Q to go back to Word and I saved the template and
then I created a macro in that template called AutoNew which
essentially said UserForm1.Show.

So then I saved it and closed it and went to File, New, From my
Computer and selected it and the dialog box popped up and I filled in
all the variables and clicked on the button and it just keeps telling
me "Runtime error 5941. Teh requested member of the collection does
not exist. I have to tell you - it's making me crazy!

Any suggestions you might have would be extremely welcome at this
point. Thanks again.



"Carol" wrote:

Thanks for all the input. This is not a protected form but, rather, a
template that I am configuring so that when it is selected, a dialog
box (user form) will pop up to fill in the variables needed for the
document to be complete. I am going start over from scratch today
and will report on my success/failure. Thanks again!

"Jay Freedman" wrote:

And to answer your question about Alt+F9:

- It's a toggle; every time you press Alt+F9, it either displays the
field codes if the field results are showing, or it displays the
field results if the field codes are showing. Press it twice and
you're back where you started.

- Alt+F9 by itself does not update the fields. That function is
performed by F9 (without the Alt) for any fields that are currently
selected; or by printing or going into Print Preview (assuming the
"Update fields" option is checked in the Tools Options Print
dialog); or, as Suzanne said, by having "Calculate on exit" checked
for a form field in a protected form when that form field is the
source for the Ref field.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

On Tue, 29 Mar 2005 22:59:28 -0600, "Suzanne S. Barnhill"
wrote:

You can insert the cross-references using Insert | Reference |
Cross-reference. You need to check the "Calculate on exit" box in
the Form Field Options for the form field. When the document is
protected, the cross-references will update automatically when the
Decedent field is filled in.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

"Carol" wrote in message
...
I have a legal document that I am using to teach myself how to
create user forms with dialog boxes to fill in the variables to
populate the document. One of the variables is the word Decedent.
This particular variable show up in multiple places in the
document. For the first instance I add a bookmark and for all
subsequent instances I click on Insert | Field and select ref and
click on the bookmark that I want it to reference. I guess the
part that I'm seemingly fouling up is this: Once I have done that
in the template do I use Alt+F9 to update each time I create a
reference or do I do that after I have completed the entire
document? I am having several problems, but I would like to
resolve this one first and then move on to the next step. I do
appreciate all of your help. Thanks again.

"Suzanne S. Barnhill" wrote:

Did you insert the braces using Ctrl+F9?

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA
Word MVP FAQ site: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

"Carol" wrote in message
...
Hello Jay,

Yes, I did toggle the field codes and all it shows is the field
code.
When
I
use Alt +F9, it shows nothing else. I'm sure it's something very
simple
that
I'm just not getting. Thanks for your help.

"Jay Freedman" wrote:

If you mean that you're seeing something like

{ REF bookmarkname }

in the document, press Alt+F9 to toggle from field codes to
field results (or go to Tools Options View and uncheck
"Field codes" which does the same thing).

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org

On Tue, 29 Mar 2005 10:49:02 -0800, "Carol"
wrote:

Thanks for your help, but I guess I'm being obtuse. I have
inserted fields and selected Ref and selected the bookmark I
want it to refer to
but
I'm
still only getting the field showing. Is there perhaps
another way of updating this template? Thanks again.

"Jay Freedman" wrote:

On Mon, 28 Mar 2005 17:03:02 -0800, "Carol"
wrote:

I have a legal document that I am creating a user form for
such that, when the template is opened, a dialog box
appears and the user can
fill
in the
variables and then the document is populated with that
information.
I am
using Bookmarks in this regard, however, one of the
bookmarks appears in numerous places within the document
and when I add the bookmark
to
the second
place it disappears from the first place, etc. My
question is
how
do I
resolve this problem? Any help would be greatly
appreciated. Thanks in advance.

You can use any bookmark name only once per document, as you
found out. In all the otoher places, insert REF fields
(Insert Field, select REF from the list) that refer to the
bookmark. The fields will repeat the contents of the
bookmark. You'll need to update the fields after filling in
the bookmark -- most easily by going to Print Preview and
back.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org