PDA

View Full Version : Displaying a form on document load



WildChildX
10-15-2006, 04:12 PM
Hey, I am new here :hi:

I am sorry if this has been posted here before but I can not seem to find an answer.

I have been using VBA inside Excel for about 6 months now and am now trying to use it in Word 2003. I have everything I what working but I can not seem to make the form appear as soon as the document opens. What I have is a letter pre typed and a form that when a user enters information into the text boxes and clicks submit the information is entered into parts of the letter. I currently have this...


Option Explicit

Private Sub Document_New()
frmInterviewInvitation.Show
End Sub

The form name has been chacked and double checked.

inside the 'ThisDocument' tab under the Microsoft Word Objects folder but it just won't appear. :(

Any help would be greatly appreciated. : pray2:

Andy

P.S Once again, sorry if this has been answered previously or if I am making a simple mistake.

mdmackillop
10-15-2006, 05:21 PM
Hi X
Welcome to VBAX
Your code will work if placed in a template. It will open the userform with the new document.
If you want the form with an existing document, use Document_Open.

Private Sub Document_Open()
frmInterviewInvitation.Show
End Sub

WildChildX
10-16-2006, 02:15 AM
Hi X
Welcome to VBAX
Your code will work if placed in a template. It will open the userform with the new document.
If you want the form with an existing document, use Document_Open.

Private Sub Document_Open()
frmInterviewInvitation.Show
End Sub



Hi mdmackillop,

I have chaged the code to...


Option Explicit
Public Sub Document_Open()
frmInterviewInvitation.Show
End Sub


and it is still not working.

EDIT: I have chaged it now. I created a module and used the AutoOpen() function.

Andy

lucas
10-16-2006, 07:01 AM
If you put Malcolms code:
Private Sub Document_Open()
frmInterviewInvitation.Show
End Sub
in the thisdocument module it will work.