creating a userform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have tried to create a userform and it doesn't seem to be working properly.
I keep coming up with the error "method or data member not found". Also I
don't know how to change the name of the userform or the commandbutton. I'm a
total beginner at this, and any help would be greatly appreciated!

Thanks!
Jill
 
Jill said:
I have tried to create a userform and it doesn't seem to be working
properly. I keep coming up with the error "method or data member not
found". Also I don't know how to change the name of the userform or
the commandbutton. I'm a total beginner at this, and any help would
be greatly appreciated!

Thanks!
Jill

See http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm and
http://www.dragondrop.com/wordcoding/word011a.asp for tutorials about
userforms.

The error message means you've tried to use something that doesn't exist.
There's no way to tell what it is without seeing the code. Paste it into a
reply to this post (no attachments, please!) and point out which line has
the highlight when the error occurs.
 
I actually figured it out!! I put in the wrong name for the userform!! Thanks
so much for your help!!
 
Okay, so I didn't figure it out. THis is what is happening now.

Sub AutoNew()
'
' AutoNew Macro
' Macro recorded 9/1/2005 by Matthew Pearson
'
ClientName.Show
End Sub

The ClientName.Show is highlighted saying Object Needed.

I also had a question on one of the links you sent me. In the create a
userform link it says in step 6 to dimension the textbox. What does that mean?

Thanks
 
One more problem.....I just tried to make a userform with a command button
and didn't change any of the names or anything. I just wanted to try to do it
plainly (if that makes any sense) and this is what I came up with.

Private Sub CommandButton1_Click() -this is highlighted

With ActiveDocument
.Bookmarks("ClientName").Range_
.InsertBefore TextBox1
End With

UserForm1.Hide
End Sub
 
The error message is telling you that you used the wrong name. The part
before the .Show should be the userform's name.

To see what that is, look in the Project pane on the left side of the VBA
editor. The AutoNew macro is stored in a module, which is like a file
folder. If you recorded a macro, it would by default be put into a module
named NewMacros, but if you used the Insert > Module command on the editor's
menu then the default name of the module is Module1. In the same project
with that module, you should see a folder called Forms, and inside that
there will be a useform. The default name of the userform is UserForm1, but
you can rename it by selecting it, displaying the Properties pane, and
changing the value in the Name box.

The probable situation is that your userform is still named UserForm1, and
there isn't yet anything named ClientName. You can rename UserForm1 as
ClientName, or you can change the AutoNew code to call UserForm1.Show. I
think it's better to rename the userform to indicate what it's used for.

If you go on to read the article at dragondrop.com, in Step 9 you'll see
another way of calling a userform, involving a New statement. You'll get
there eventually. :-)

When step 6 of the first article says to dimension the textbox, it just
means "make it large enough to hold the text you expect to be typed into
it". You do that by grabbing an edge or corner of the box with the mouse and
dragging it.
 
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

Back
Top