像这样:
Dim uf As UserForm1
Set uf = New UserForm1
uf.Show False
但是,这不是一个好的做法,因为通知应该是模态的。也许您想要SystemModal(在所有窗口前面)而不是ApplicationModal(在应用程序前面)? VBA MsgBox 实际上可以完全自定义,请查看this post here to learn more on how to customize a MsgBox。
使窗口置顶
如果您希望表单窗口成为 TopMost,请尝试以下操作:
https://support.microsoft.com/en-us/kb/184297
Option Explicit
Public Const SWP_NOMOVE = 2
Public Const SWP_NOSIZE = 1
Public Const FLAGS = SWP_NOMOVE Or SWP_NOSIZE
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" _
(ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, _
ByVal x As Long, _
ByVal y As Long, _
ByVal cx As Long, _
ByVal cy As Long, _
ByVal wFlags As Long ) As Long
Public Function SetTopMostWindow(hwnd As Long, Topmost As Boolean) _
As Long
If Topmost = True Then 'Make the window topmost
SetTopMostWindow = SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, _
0, FLAGS)
Else
SetTopMostWindow = SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, _
0, 0,FLAGS)
SetTopMostWindow = False
End If
End Function
要在您的表单上使用它:
res = SetTopMostWindow(uf.hwnd, True)