Print side | Luk vindue

Splash Screen

Udskrevet fra: Dansk Regneark Forum
Kategori: Hjælp til regneark.
Forum navn: Makro og VBA
Forum beskrivelse: Hjælp til Makroer og VBA-programmering
Web-adresse: https://forum.excel-regneark.dk/forum_posts.asp?TID=3703
Udskrevet den: 23.Nov.2024 kl. 09:59


Emne: Splash Screen
Besked fra: Kenny.E
Emne: Splash Screen
Posteringsdato: 04.Dec.2018 kl. 01:22
Hej jeg har fundet det her på nettet  kan det laves så det åbner en Userform efter load ?
Hilsen
Kenny
Smile
'PLACE IN YOUR USERFORM CODE
Private Sub UserForm_Activate()
    Application.Wait (Now + TimeValue("00:00:01"))
    SplashUserForm.Label1.Caption = "Loading Data..."
    SplashUserForm.Repaint
    Application.Wait (Now + TimeValue("00:00:01"))
    SplashUserForm.Label1.Caption = "Creating Forms..."
    SplashUserForm.Repaint
    Application.Wait (Now + TimeValue("00:00:01"))
    SplashUserForm.Label1.Caption = "Opening..."
    SplashUserForm.Repaint
    Application.Wait (Now + TimeValue("00:00:01"))
    Unload SplashUserForm
End Sub
-------------------------------------------------------------------------------------------------------------------------

'PLACE IN A STANDARD MODULE
Option Explicit
Option Private Module

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

Sub HideTitleBar(frm As Object)
    Dim lngWindow As Long
    Dim lFrmHdl As Long
    lFrmHdl = FindWindowA(vbNullString, frm.Caption)
    lngWindow = GetWindowLong(lFrmHdl, GWL_STYLE)
    lngWindow = lngWindow And (Not WS_CAPTION)
    Call SetWindowLong(lFrmHdl, GWL_STYLE, lngWindow)
    Call DrawMenuBar(lFrmHdl)
End Sub
-----------------------------------------------------------------------------------------------------------------------

'PLACE IN YOUR USERFORM CODE
Private Sub UserForm_Initialize()
    HideTitleBar Me
End Sub
--------------------------------------------------------------------------------------------------------------------------
'PLACE IN ThisWorkbook SHEET MODULE
Private Sub Workbook_Open()
    Application.ScreenUpdating = False
    ActiveWindow.Visible = False
    SplashUserForm.Show
    Windows(ThisWorkbook.Name).Visible = True
    Application.ScreenUpdating = True
End Sub




Svar:
Besked fra: maxzpad
Posteringsdato: 05.Dec.2018 kl. 08:44
Hej Kenny

Hvis du følger alle de instruktioner, som er anført ("PLACE xx IN yy"), bør det virke ... dvs. at Userform'en vises, når den projektmappe, den er placeret i, åbnes. Men du skal også have defineret selve Userform'en via Insert -> UserForm.

Det er denne her Workbook_Open-event, som trigger, at den vises (såfremt makroer er tilladt):

'PLACE IN ThisWorkbook SHEET MODULE
Private Sub Workbook_Open()
    Application.ScreenUpdating = False
    ActiveWindow.Visible = False
    SplashUserForm.Show
    Windows(ThisWorkbook.Name).Visible = True
    Application.ScreenUpdating = True
End Sub

Håber det hjælper dig videre.

Mvh Max


Besked fra: Kenny.E
Posteringsdato: 05.Dec.2018 kl. 18:15
Hej Max jeg fik det løst med det her.

'PLACE IN ThisWorkbook SHEET MODULE
Private Sub Workbook_Open()
    Application.Visible = False
    SplashUserForm.Show
    Windows(ThisWorkbook.Name).Visible = False
    UserForm2.Show
End Sub

Tak for hjælpen
Hilsen
Kenny



Print side | Luk vindue