话不多说上代码
问题出在userform这个窗体的样式上
需要用到的win32api函数以及常量
Public Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPtr
Public Const WS_POPUP = &H80000000
Public Const GWL_STYLE = (-16)
Public Declare PtrSafe Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long) As Long
Public Declare PtrSafe Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As LongPtr, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
用户窗体的初始化
Private Sub UserForm_Initialize()
Dim hd, s As Long
hd = Win32Api.FindWindow(vbNullString, Me.Caption)
s = Win32Api.GetWindowLong(hd, Win32Api.GWL_STYLE)
If s And Win32Api.WS_POPUP = Win32Api.WS_POPUP Then
s = s Xor Win32Api.WS_POPUP
Win32Api.SetWindowLong hd, Win32Api.GWL_STYLE, s
End If
End Sub
Public Sub Mycmd_测试窗体()
UserForm1.show 0
End Sub
标签:模态,VBA,AutoCAD,Sub,ByVal,Long,WS,Public,Win32Api From: https://www.cnblogs.com/NanShengBlogs/p/18621051