UserForms +Error

G

Griff

Hi
I've created a test document with a UserForm as detailed in the
CreateAUserFormContent.htm document
(http://www.word.mvps.org/FAQs/Userforms/CreateAUserForm.htm).

I have followed the instructions, however, when I open my new template I get
the following error:

Run-time error '424':
Object required

I click on debug and under "NewMacroCode" UserForm1.Show is highlighted.
My UserForm is called UserForm1....so any suggestions as to where I am going
wrong?

Thanks in advance
 
J

Jean-Guy Marcil

Griff was telling us:
Griff nous racontait que :
Hi
I've created a test document with a UserForm as detailed in the
CreateAUserFormContent.htm document
(http://www.word.mvps.org/FAQs/Userforms/CreateAUserForm.htm).

I have followed the instructions, however, when I open my new
template I get the following error:

Run-time error '424':
Object required

I click on debug and under "NewMacroCode" UserForm1.Show is
highlighted. My UserForm is called UserForm1....so any suggestions as
to where I am going wrong?

When in the Debug mode, (When your line "UserForm1.Show" is highlighted),
hit F8 to execute the code step by step. This will take you to the
Initialize or Activate code of the Userform.

There is something in there that is causing the problem.

Either you will be able to fix it when you get to the line that creates the
problem in the userform code or you will be able to post back with more
explicit details to your problem.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
G

Griff

Hi

I've pressed F8, and all I get is...

Run-time error '424', Object required...

It doesn't do anything else
 
J

Jean-Guy Marcil

Griff was telling us:
Griff nous racontait que :
Hi

I've pressed F8, and all I get is...

Run-time error '424', Object required...

It doesn't do anything else

Then, this means that there is a name error.

Just to test this name, create a new module in your template project, then
create a Sub like this:
Type:
Sub TestUserForm
and hit Enter. You should now have

Sub TestUserForm()

End Sub

Place the cursor between the Sub and End Sub statement and type:

UserForm1

and now type a period "." right after UserForm1.

Automatically, you should have a list of available methods/properties that
are available to UserForm1. This is called the VBE IntelliSense.

If you do not have a list hat pops ups, then it means there is name error
and your userform is not called UserForm1 as you think it is. Double check
the Userform name form the Project browser pane (Top left part of the VBE
window).

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jay Freedman

The usual problem with the code in that example is that when people retype
it (instead of cut/paste), they don't realize that in step 10 there must be
a space between the word Range and the underscore in each of two places.
That's a line-continuation character (see
http://www.word.mvps.org/FAQs/MacrosVBA/_AtEndOfLine.htm).

When you omit the space, the statement isn't continued to the next line. VBA
sees the .InsertBefore method as the start of a new statement, so it
complains that you haven't provided an object for the method to belong to --
the object should be the Range in the preceding line.

Unfortunately, whenever there's a compile error like that in userform code,
the debugger stops on the line that shows the userform, not on the actual
error. It's one of those things you learn by experience. :-(

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