Home |
Search |
Today's Posts |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|
Similar Threads | ||||
Thread | Forum | |||
CommandButton on printout | Page Layout |