UserForm error

D

Diana Morrison

I am having trouble with an error message: Compile error: method or data
not found (followed "How to create a Userform" by Doug Robbins). So, I
created a test document following the exact instructions in the same article
and I still get the same message. Can you help?
 
J

Jay Freedman

The probable reason, if you retyped the code instead of using cut&paste, is
that you didn't put in the space before the underscore at the ends of the
lines in

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

Because of the font of the web page, those spaces are hard to see, but VBA
requires them.

For an explanation of the underscores, see
http://word.mvps.org/FAQs/MacrosVBA/_AtEndOfLine.htm.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
G

Greg Maxey

Ah,

Pull the lines together to eliminate the underscore:

..Bookmarks("Text1").Range.InsertBefore TextBox1
and
..Bookmarks("Text2").Range.InsertBefore TextBox2
 
D

Diana Morrison

You're right - worked instantly! Thanks so much.

Any recommended reading on this subject? I'd like to be able to better
understand and work with vba for Word.

Thanks!
Diana
 
J

Jay Freedman

Glad I could help.

For reading, start at
http://www.word.mvps.org/FAQs/MacrosVBA/VBABasicsIn15Mins.htm and then
read anything else at http://word.mvps.org/FAQs/MacrosVBA/index.htm
and http://word.mvps.org/FAQs/Userforms/index.htm that looks
interesting.

Then go look at the articles and books listed at
http://word.mvps.org/Tutorials/index.htm and
http://word.mvps.org/Tutorials/FreeToAccess.htm.

Of course, if you still have questions, ask them here!

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.
 

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