Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

An information screen to pop up in word????

Status
Not open for further replies.

Toby1kenobe

Instructor
May 26, 2002
66
GB
Hi

I've been using VBA with access for a while so fust presumed that it would be easy to build some code for WORD, oh no. I want a form to popup containing a picture and some information with a button to close it. I've created the form 'Userform1' and tried to atatch it to the on open event of my document. As yet i'm failing. Also I cant make the button close the form.

I've tried

forms!userform1.openform

and it can't find userform1

Any help is always greatly appreciated
Toby
 
Try
Code:
Load Userform1
Userform1.Show

And on your button:
Code:
Userform1.Close

Hope that helps!

VBAjedi [swords]
 
Very simply, put this on the code page for "ThisDocument":
Code:
Private Sub Document_Open()
  UserForm1.Show
End Sub
And put this on the code page for "UserForm1"
Code:
Private Sub CommandButton1_Click()
  Me.Hide
End Sub

 
Zathras,

Just out of curiosity: won't Me.Hide leave the form still loaded into memory? What advantage do you see in doing it that way?

VBAjedi [swords]
 
Good point, Jedi.

It sounded like an "About" box to me, in which case Toby may eventually provide a way for the user to re-display it.

In any event, I don't think it would eat too much memory. However, your point is well taken, and memory usage should always be considered.

BTW, I couldn't find the syntax UserForm1.Close in Word 97 SR-1. The code that works there is
Code:
Private Sub CommandButton1_Click()
  Unload Me
End Sub
 
Zathras,

Yup, I was going from recall on how to remove the form from memory. Good catch! Let's all just pat each other on the back and be friends. . .

Tobe1kenobe (hey, any relation to my mentor Obiewan? LOL ), hope somewhere in here we gave you a working solution.

VBAjedi [swords]
 
Thanks to all contributing jedi VBA masters!

All help is always much appreciated.
I'll try the code tomorrow at work

Long live Tek Tips-and friendly banter!!
Toby
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top