Macro trouble - repeating data fill-in

S

SharonC

I've read through all the posts I could find regarding entering repeating
data in a form. I went to
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm as instructed, but I
am getting an error.

On that page, step 10, where you are defining bookmarks with this code:

Enter the following code between the Private Sub CommandButton1_Click() and
theEnd Sub

With ActiveDocument
.Bookmarks("Text1").Range _
.InsertBefore TextBox1
.Bookmarks("Text2").Range _
.InsertBefore TextBox2
End With

UserForm1.Hide

I get an error message with .Range_ highlighted. The message says "method
or data member not found". What is ".range_" referring to here? Am I
supposed to replace something with my own text (I replaced "text1" and
Textbox1 with my own text and textbox labels as instructed. What am I
missing? I'm sure it is staring me in the face!

Sharon
 
C

Charles Kenyon

Bookmarks are incredibly fragile. If you are using text form fields, you
don't want to be replacing them, but rather filling them in. Why are you
using these formfields rather than regular bookmarks?

Some additional pages you'll want to review.
http://word.mvps.org/FAQs/MacrosVBA/InsertingTextAtBookmark.htm
http://gregmaxey.mvps.org/Repeating_Data.htm

--
Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide


--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
 
J

Jay Freedman

Hi Sharon,

You got zapped by a tiny problem that hits about half the new users who try
that code. :-( You retyped the code into the editor, instead of using
copy/paste, and you missed the fact that there's a space between the word
Range and the underscore at the end of the line. The underscore is VBA's
"continuation character" to say that the same statement continues onto the
next line -- but it *must* be separated from the preceding text by a space,
or else it won't be recognized. See
http://word.mvps.org/FAQs/MacrosVBA/_AtEndOfLine.htm for a discussion.
 

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