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
Jean-Guy Marcil - 13 Sep 2006 12:11 GMT
Griff was telling us:
Griff nous racontait que :
> Hi
> I've created a test document with a UserForm as detailed in the
[quoted text clipped - 10 lines]
> 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.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Griff - 13 Sep 2006 12:25 GMT
Hi
I've pressed F8, and all I get is...
Run-time error '424', Object required...
It doesn't do anything else
> Griff was telling us:
> Griff nous racontait que :
[quoted text clipped - 23 lines]
> problem in the userform code or you will be able to post back with more
> explicit details to your problem.
Jean-Guy Marcil - 13 Sep 2006 12:37 GMT
Griff was telling us:
Griff nous racontait que :
> Hi
>
[quoted text clipped - 3 lines]
>
> 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).

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
Jay Freedman - 13 Sep 2006 20:04 GMT
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. :-(

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
> Hi
> I've created a test document with a UserForm as detailed in the
[quoted text clipped - 12 lines]
>
> Thanks in advance