Membuat “Splash Screen” pada Excel dengan VBA

Bagaimana membuat “Splash Screen” sebagai intro  ketika file excel kita buka (klik).  Berikut ini script yang saya peroleh dari buku excel 2013 power programming with VBA – John WalkenBach.

splahScreen

Script pada UserForm

Option Explicit

Const GWL_STYLE = -16
Const WS_CAPTION = &HC00000
Private Declare PtrSafe Function GetWindowLong Lib “user32” Alias “GetWindowLongA” (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Private Declare PtrSafe Function SetWindowLong Lib “user32” Alias “SetWindowLongA” (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare PtrSafe Function DrawMenuBar Lib “user32” (ByVal hWnd As Long) As Long
Private Declare PtrSafe Function FindWindowA Lib “user32” (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

‘Script untuk menghilangkan bingkai window pada UserForm

Private Sub UserForm_Initialize()
Dim lngWindow As Long, lFrmHdl As Long
lFrmHdl = FindWindowA(vbNullString, Me.Caption) ‘ The UserForm must have a caption
lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
lngWindow = lngWindow And (Not WS_CAPTION)
Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
Call DrawMenuBar(lFrmHdl)
End Sub

‘Script untuk Splash Screen

Private Sub UserForm_Activate()
Application.OnTime Now + TimeValue(“00:00:05”), “KillTheForm”
End Sub

‘Prosedur untuk tombol test splash screen dan  “KillTheForm”

Sub TestSplashScreen()
With UserForm1
.StartUpPosition = 0
.Left = Application.Left + (0.5 * Application.Width) – (0.5 * .Width)
.Top = Application.Top + (0.5 * Application.Height) – (0.5 * .Height)
.Show
End With
End Sub

Private Sub KillTheForm()
Unload UserForm1
End Sub

download file contoh : splash Screen 

Author: Abdul Karim

Integrasi Matematika dan Teknologi merupakan fokus perhatian saya, dalam memberikan kontribusi kepada pendidikan matematika di Indonesi

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s