View Full Version : How to start a form when opening a word doc
bobulos
01-08-2007, 04:48 AM
Hi ,
How do I start a userform when opening a word doc ?
e.g when I open mydoc.doc a userform is displayed straight away.
Thanks in advance
fumei
01-08-2007, 05:32 AM
Use the Document_Open event.
1. open the VBE (Alt-F11)
2. if Project Explorer is not visible, press Ctl-R.
3. navigate to the document in question. It is shows as something like: (Project mydoc.doc).
4. if the ThisDocument module is not visible, expand the project by clicking the little plus sign
5. double click the ThisDocument module to open it.
6. from the LEFT dropdown (at the top of the code module window), select Document. This will automatically write a blank Document_New procedure. You can delete this.
7. with Document showing in the LEFT dropdown, click the RIGHT dropdown, and select Open. This will automatically write a blank Document_Open procedure.
8. put in the code to .Show the userform. Like this:Sub Document_Open()
Userform1.Show
End Sub
9. save the file.
Now when the document is opened Userform1 will be displayed.
fumei
01-08-2007, 05:34 AM
PS, as this seems to be new to you, I want to suggest you make sure that whatever you do with your userform, when you are done with it use Unload (syntax: Unload Me) to cleanly close it.
fumei
01-08-2007, 05:35 AM
oh, and BTW: Welcome to VBAX!
bobulos
01-08-2007, 05:51 AM
many thanks , btw I had to change the security of the macros inorder for the form to display
fumei
01-08-2007, 06:30 AM
Yes, of course you do. You can not have it as High. It must be Medium or Low.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.