PDA

View Full Version : Solved: Splash Screen UserForm time delay and dll issues?!



Dal1981
12-05-2011, 04:49 AM
Hi all, please help!

I have a userform ("UF_Splash") that is driving me mad. :banghead:

It's a splash screen userform of just the company logo, I want this on openeing the workbook up. So, on workbook Open I have just "Load UF_Splash" which triggers the following:


Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub UserForm_Initialize()
UF_Splash.Show
Do Until i = 5
i = i + 1
Range("A1") = i

Sleep 1000

Loop

UF_Splash.Hide 'I put this in just on testing to see if its working = or where its stopping

Unload UF_Splash

Load UF_Main 'This triggers the next step / userform to open under its own initialize - but I've removed this in testing just till I (Ed. you!!) solve the above

End Sub
----------------

The form loads, then stays open. Thats the issue. 'Sleep' isn't working and I have to queryclose the userform, which when i do, it reopens automatically?! I figure there must be something obvious im overlooking ...please advise. Many thanks!

Aflatoon
12-05-2011, 06:26 AM
I would suggest you alter the Load statement to:
Dim frmSplash as UF_Splash
Dim frmMain as UF_Main
Set frmSplash = New UF_Splash
frmSplash.Show
set frmSplash = Nothing
Set frmMain = New UF_Main
frmMain.Show
and then remove the Initialize event of the splash form, replacing it with an Activate event:

Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub UserForm_Activate()
For i = 1 to 5

Range("A1") = i

Sleep 1000

Next i

Me.Hide

End Sub

Dal1981
12-05-2011, 07:01 AM
Thanks Aflatoon, Almost Perfect ... got a compile err as I changed my other user form name to UF_Home (!!) ... but works a treat.

I do have another issue ... can I post on here? ...

The UF_Splash consists of a picture of my company logo. When I open the userform straight from a commandbutton, it opens as usual - but using the above code the Userform does not load the picture within it? Is there a logical reason for this...should I 'load' the form before showing?

Thanks again for your time :)

Aflatoon
12-05-2011, 07:04 AM
I would suggest adding:
Me.Repaint
DoEvents
as the first two lines of the Activate event code, and see if that resolves it.

Dal1981
12-05-2011, 07:26 AM
indeed it does. Many thanks again, I've the foundations of a really professional looking reporting suite now :)