Userform at Startup in MS Word

T

TomP

How do I get a userform to appear whenever a document is opened? After the
"enable macros?", I would like to have the form appear. The form would just
have text briefly explaining how to use the document. In the form, I have
one command button that will close the form which I need help also.

Thank you for your help!

Tom
 
G

Greg Maxey

Tom,

You want a standard module to contain code that calls the Userform when the
document is opened:

Sub Document_Open()
Dim oFrm As UserForm1
Set oFrm = New UserForm1
oFrm.Show
Unload oFrm
Set oFrm = Nothing
End Sub

Your UserForm should have a lable (e.g., Label1) for the informative text
and a command button.

Code that you could use in the UserForm module would look like this:

Private Sub CommandButton1_Click()
Me.hide
End Sub

Private Sub UserForm_Initialize()
Me.Label1.Caption = "This is how you use this document. Add as much text as
you want here. " _
& "Use character return to create a new paragraph like
this" & vbCr & vbCr _
& "Blah, blah, blah."
End Sub
 
N

NFL

Thank you! It works great!

Greg Maxey said:
Tom,

You want a standard module to contain code that calls the Userform when the
document is opened:

Sub Document_Open()
Dim oFrm As UserForm1
Set oFrm = New UserForm1
oFrm.Show
Unload oFrm
Set oFrm = Nothing
End Sub

Your UserForm should have a lable (e.g., Label1) for the informative text
and a command button.

Code that you could use in the UserForm module would look like this:

Private Sub CommandButton1_Click()
Me.hide
End Sub

Private Sub UserForm_Initialize()
Me.Label1.Caption = "This is how you use this document. Add as much text as
you want here. " _
& "Use character return to create a new paragraph like
this" & vbCr & vbCr _
& "Blah, blah, blah."
End Sub
 

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