PDA

View Full Version : Solved: Splash Screen



rockwellsba
10-26-2009, 11:32 AM
Hello- I would appreciate anyone's help on this.

I have a UserForm (UserForm1) with the following code in General/Declarations:

Private Sub CommandButton1_Click()
'' Validate all TextBoxes
If TextBox1.Text = "" Then
MsgBox "Name Of Applicant field is not complete"
TextBox1.SetFocus
Exit Sub
End If
If TextBox2.Text = "" Then
MsgBox "Contact Name field is not complete"
TextBox2.SetFocus
Exit Sub
End If
If TextBox3.Text = "" Then
MsgBox "Applicant Phone field is not complete"
TextBox3.SetFocus
Exit Sub
End If

'If we got here, textboxes have valid input
'Put valid inputs into document
With ActiveDocument
.Bookmarks("NameOfApplicant").Range _
.InsertBefore TextBox1.Text
.Bookmarks("ContactName").Range _
.InsertBefore TextBox2.Text
.Bookmarks("ApplicantPhone").Range _
.InsertBefore TextBox3.Text
End With

''We got this far, must be ready to close the dialog
Unload Me
'End If

End Sub
I also have UserForm2 which is the Splash Screen. Its code (in UserForm/Initialize) is:

Private Sub UserForm_Initialize()
Application.OnTime Now + TimeValue("00:00:05"), "KillForm"
End Sub

I have two modules. Module1 (General/Autonew) code:

Sub autonew()
'
' autonew Macro
'
'
UserForm1.Show
End Sub
Module2 (General/KillForm) code:

Sub KillForm()
Unload UserForm2
End Sub
And lastly, code for ThisDocument (Document/Open):

Private Sub Document_Open()
UserForm2.Show
End Sub
When I open the template, the splash screen (UserForm2) does not show. UserForm1 shows up just fine. Any help would be greatly appreciated. Thank you!

rockwellsba
10-26-2009, 11:43 AM
Newest development: The splash screen (tithe the previously posted code) does show but does not go away. If I click the "X" it goes away but the UserForm1 does not show. Ideally, I'd like the splash screen to go away on its own and then the UserForm1 show. Sorry about any confusion and as always, any help is appreciated.

rockwellsba
10-26-2009, 11:49 AM
Please don't kill me.

When I open the .dotm file, the splash screen shows but doesn't go away unless I click the "X". UserForm1 doesn't come up after clicking "X". If I open a new template (Office Button, New, Recently Used Templates, Create), the UserForm1 shows but the splash screen does not. I'm going crazy. Ant help?

lucas
10-27-2009, 08:28 AM
You need to call the timer from userform2 which is the splash screen

It needs to be called from the thisworkbook module with document open unless you are using a template in which case you would use document new.

After you call the unload code you need to call userform1 from userform 2.

It would help if you could post your document.

lucas
10-27-2009, 09:08 AM
I had never tried to make a splash for Word but I encountered a few problems with on time so try this, it works in 2003. All code goes in the splash screen module, no standard module with a killform procedure....

In the thisdocument module:
Option Explicit
Private Sub Document_New()
Userform1.Show
End Sub


In the module for the splash screen( my splash is userform1):
Option Explicit
Private Declare Sub Sleep Lib "kernel32" _
(ByVal dwMilliseconds As Long)
Private Sub Label1_Click()
End Sub
Private Sub UserForm_Activate()
DoEvents
Sleep 3000
Unload Me
UserForm2.Show
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, _
CloseMode As Integer)
Cancel = CloseMode = 0
End Sub


It closes and calls userform2.

Note: to use as a template, change the open procedure in the thisdocument module to a document new procedure. Both examples are included in the attached zip.

rockwellsba
10-27-2009, 11:02 AM
Lucas-
Works like a charm. Perfect. I appreciate it very much. I spent way too much time hitting my head against the wall on this.
-Phil

lucas
10-27-2009, 11:11 AM
You're welcome, you can mark your thread solved using the thread tools at the top of the page.