Option Explicit
Private Declare Function SetTimer Lib "user32.dll" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long, _
ByVal uElapse As Long, _
ByVal lpTimerFunc As Long) As Long
Private Declare Function KillTimer Lib "user32.dll" _
(ByVal hwnd As Long, _
ByVal nIDEvent As Long) As Long
Private Declare Function ShowWindow Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" _
Alias "FindWindowA" ( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long
Private Declare Function GetProp Lib "user32" _
Alias "GetPropA" _
(ByVal hwnd As Long, _
ByVal lpString As String) As Long
Private Declare Function SetProp Lib "user32" _
Alias "SetPropA" _
(ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal hData As Long) As Long
Sub Loader()
Dim oVBE As Object
Dim MSG1 As String
Dim MSG2 As String
MSG1 = "You need to allow access to the VBAProject to load the userform."
MSG2 = "Sorry... you need to allow access to the VBAProject to load the userform."
If GetProp(Application.hwnd, "SubClassingIsSafe") = 0 Then
On Error Resume Next
Set oVBE = Application.VBE
If oVBE Is Nothing Then
MsgBox MSG1
Application.CommandBars.FindControl(ID:=3627).Execute
Set oVBE = Application.VBE
If oVBE Is Nothing Then
MsgBox MSG2: Exit Sub
End If
End If
On Error GoTo 0
With Application.VBE.CommandBars
.FindControl(ID:=189).Execute
.FindControl(ID:=228).Execute
End With
End If
SetTimer Application.hwnd, 0, 1, AddressOf LoadFormNow
End Sub
Public Sub LoadFormNow()
Dim lVBEhwnd As Long
KillTimer Application.hwnd, 0
Call SetProp(Application.hwnd, "SubClassingIsSafe", 1)
lVBEhwnd = FindWindow("wndclass_desked_gsk", vbNullString)
ShowWindow lVBEhwnd, 0
#If VBA6 Then
frmTask.Show vbModeless ' Show the form modeless.
#Else
Sorry
#End If
End Sub
Sub Sorry()
Dim MSG As String
MSG = "Sorry .... dosen't run on Versions < 2000!"
MsgBox MSG, vbExclamation
'Application.UserControl = False
'Application.IgnoreRemoteRequests = True
End Sub