Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2005

Tip: Looking for answers? Try searching our database.

Unloading a User Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 11 Mar 2005 19:48 GMT
Hi

I have created some User Forms that populate a variety of templates e.g
letters, memo's etc.  However, whenever someone opens an old document
that has been produced with a User Form, and has then been saved, the
User Form appears again!  Is there a way of stopping that happening?

Thanks

Dave
Jonathan West - 11 Mar 2005 20:14 GMT
> Hi
>
> I have created some User Forms that populate a variety of templates e.g
> letters, memo's etc.  However, whenever someone opens an old document that
> has been produced with a User Form, and has then been saved, the User Form
> appears again!  Is there a way of stopping that happening?

What means do you use to make the userform show automatically?

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Dave - 11 Mar 2005 20:29 GMT
Hi Jonathan

In my templates I use:

Sub AutoNew()
'
' AutoNew Macro
' Macro created 28/02/05 by DG .
'
frmLetter.Show
End Sub

Dave

>> Hi
>>
[quoted text clipped - 5 lines]
>
> What means do you use to make the userform show automatically?
Jonathan West - 11 Mar 2005 20:33 GMT
OK, that's the right way to do it. I assume that the AutoNew macro is in the
VBA project in the template, along with the UserForm itself.

Is there an AutoOpen macro as well?

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

> Hi Jonathan
>
[quoted text clipped - 18 lines]
>>
>> What means do you use to make the userform show automatically?
Dave - 11 Mar 2005 21:08 GMT
Yes to all of the questions re the AutoNew, and there is no AutoOpen

Dave

> OK, that's the right way to do it. I assume that the AutoNew macro is in
> the VBA project in the template, along with the UserForm itself.
>
> Is there an AutoOpen macro as well?
Jonathan West - 11 Mar 2005 21:18 GMT
> Yes to all of the questions re the AutoNew, and there is no AutoOpen

Hmmm. Is there a Document_Open event in the ThisDocument module in the
template?

When the document is re-opened, does the filename of the document appear on
the window caption, or does it say "Document n"?

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

Dave - 11 Mar 2005 22:27 GMT
Snag.  I am at home and the problem templates are at work!  I am
wondering if when I click OK and unload the userform to generate my
document, I should be doing something else at that point.  Should
another line of code follow the Unload Me line?

Thanks

Dave

>> Yes to all of the questions re the AutoNew, and there is no AutoOpen
>
[quoted text clipped - 3 lines]
> When the document is re-opened, does the filename of the document appear
> on the window caption, or does it say "Document n"?
Jonathan West - 11 Mar 2005 22:56 GMT
> Snag.  I am at home and the problem templates are at work!  I am wondering
> if when I click OK and unload the userform to generate my document, I
> should be doing something else at that point.  Should another line of code
> follow the Unload Me line?

No, Unload Me is the right thing to use to close the UserForm.

Something else, somewhere, must be causing the Userform to show up again
when the document is opened. The two obvious candidates are an Auto macro,
or an event proceure.

There's a way we can smoke this out. Change the name of the form in the
properties pane in the VBA editor from frmLetter to something else, and make
the matching change in the AutoNew macro. Make no other changes at all. Save
the template and then try to reproduce the problem. With any luck, you will
trigger an error as some piece of code tries to run a nonexistent form.
Track it down and work out what needs to be changed.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org 

Dave - 12 Mar 2005 06:50 GMT
Excellent idea.  I will try that on Monday.

Thanks

David

>> Snag.  I am at home and the problem templates are at work!  I am
>> wondering if when I click OK and unload the userform to generate my
[quoted text clipped - 13 lines]
> luck, you will trigger an error as some piece of code tries to run a
> nonexistent form. Track it down and work out what needs to be changed.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.