Autonew macro won't run

A

AnnieB

G'Day all!

Can someone please tell me why the following would suddenly stop running?

Private Sub Document_New()
UserForm1.Show
End Sub

I have created UserForm1 in my template and the form was loading correctly
on opening a new document based on that template. I have since edited the
fields on UserForm1 but the name is unchanged.

I am now getting:

Run-time Error '5941':
The requested member of the collection does not exist

Any suggestions gratefully received!
 
H

Helmut Weber

Hi,

you may try to export userform1
delete it and import it again.

But whether that helps is uncertain.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 
A

AnnieB

Okay - I went back to my form and removed some of the fields and it now
works. Is there a restriction on the number of fields that can be added to a
userform?
 
R

Russ

AnnieB,
It would be helpful if you could show us the exact line where the error
occurs. And then show us that line and its short surrounding (which event,
if on a userform) subroutine.
It may be that it is referring to a bookmark or form field or AutoText or
some other named or numbered item in a collection, in your document, that
you have not yet established or misnamed (typo?) in reference.
---------------
Some typos can be caught if you always use:
Option Explicit

in the (Declarations) section of each of your projects.
Then, the compiler forces you to correctly spell or declare a variable
before using it.
See this webpage for more information on declaring variables:
http://word.mvps.org/faqs/macrosvba/DeclareVariables.htm
 

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