Reply
 
Thread Tools Display Modes
  #1   Report Post  
Wendy D
 
Posts: n/a
Default UserForms: CommandButton Help

Hi. I'm trying to create a userform within/for a template. I've followed
the instructions he
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm.

Everything seems to have worked right except for step #10. When I create a
new document off the template, I do get the user form. But when I hit the
"CommandButton1" (or if I try and compile while in the "viewcode" of the
command button), I get a COMPILE ERROR: Method or Data Member Not Found.
When I OK the message, it highlights the .Range portion of the code.

I think I have everything the same as instructed, so I'm not sure what's
wrong. Within ViewCode of CommandButton1 (UserForm1) I have:

Private Sub CommandButton1_Click()
With ActiveDocument
.Bookmarks("ProjectName").Range_
.InsertBefore TextBox1
.Bookmarks("TaskName").Range_
.InsertBefore TextBox2
End With

UserForm1.Hide

End Sub

Anyone know how to fix me?

Thanks!
Wendy
  #2   Report Post  
Jay Freedman
 
Posts: n/a
Default

Wendy D wrote:
Hi. I'm trying to create a userform within/for a template. I've
followed the instructions he
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm.

Everything seems to have worked right except for step #10. When I
create a new document off the template, I do get the user form. But
when I hit the "CommandButton1" (or if I try and compile while in the
"viewcode" of the command button), I get a COMPILE ERROR: Method or
Data Member Not Found. When I OK the message, it highlights the
.Range portion of the code.

I think I have everything the same as instructed, so I'm not sure
what's wrong. Within ViewCode of CommandButton1 (UserForm1) I have:

Private Sub CommandButton1_Click()
With ActiveDocument
.Bookmarks("ProjectName").Range_
.InsertBefore TextBox1
.Bookmarks("TaskName").Range_
.InsertBefore TextBox2
End With

UserForm1.Hide

End Sub

Anyone know how to fix me?

Thanks!
Wendy


Hi Wendy,

Insert a space character before the underscore in each of the two Range
expressions. See

What are the underscores _ at the end of lines of code there for?
http://word.mvps.org/FAQs/MacrosVBA/_AtEndOfLine.htm

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


  #3   Report Post  
Suzanne S. Barnhill
 
Posts: n/a
Default

You might get a faster and more authoritative answer if you post in the
microsoft.public.word.vba.userforms newsgroup.

--
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.

"Wendy D" wrote in message
...
Hi. I'm trying to create a userform within/for a template. I've followed
the instructions he
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm.

Everything seems to have worked right except for step #10. When I create

a
new document off the template, I do get the user form. But when I hit the
"CommandButton1" (or if I try and compile while in the "viewcode" of the
command button), I get a COMPILE ERROR: Method or Data Member Not Found.
When I OK the message, it highlights the .Range portion of the code.

I think I have everything the same as instructed, so I'm not sure what's
wrong. Within ViewCode of CommandButton1 (UserForm1) I have:

Private Sub CommandButton1_Click()
With ActiveDocument
.Bookmarks("ProjectName").Range_
.InsertBefore TextBox1
.Bookmarks("TaskName").Range_
.InsertBefore TextBox2
End With

UserForm1.Hide

End Sub

Anyone know how to fix me?

Thanks!
Wendy


Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
CommandButton on printout bob engler Page Layout 1 August 9th 05 01:23 PM


All times are GMT +1. The time now is 04:49 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"