|
本帖最后由 huanglicheng 于 2014-4-18 14:25 编辑
不久前在别人贴中回过,现在分享出来。说不定你会喜欢。你可以改成你喜欢的样式,或者改做其他更广泛的用途。
代码在18楼有更新
利用 菜单的形式做提示框: 不需点确定
单行提示: MsgBoxa ("你好,我是一个提示框")
多行提示: MsgBoxa ("你好,我是一个提示框" & vbLf & "关闭我非常简单,随便哪点一下即可")
调用方式
- Sub test()
- MsgBoxa ("你好,我是一个提示框")
- End Sub
复制代码
- Sub MsgBoxa(myMessage, Optional myTitle As String, Optional myFaceid As Long, Optional x1 As Long, Optional y1 As Long) '菜单提示(提示内容,提示标题,图标,x位置,y位置)
- On Error Resume Next
- CommandBars("tmpContextMenu").Delete
- On Error GoTo 0
- Dim m As CommandBar, i%
- Set m = CommandBars.Add("tmpContextMenu", msoBarPopup)
- '--------------------------------------------------
- If x1 = 0 Then x1 = 400
- If y1 = 0 Then y1 = 400
- '--------------------------------------------------
- Set regex1 = CreateObject("VBSCRIPT.REGEXP") 'RegEx为建立正则表达式
- With regex1
- .Global = True '设置全局可用
- .Pattern = ".+"
- End With
- '--------------------------------------------------
- With m
- '--------------------------------------------------
- With .Controls.Add(msoControlButton, , , , True) '添加新按钮
- If myTitle = "" Then .Caption = "★SoSo提示您★" Else .Caption = myTitle
- .FaceId = 1954
- End With
- '--------------------------------------------------
- Set c = regex1.Execute(myMessage)
- If c.Count > 0 Then
- For i = 0 To c.Count - 1
- With .Controls.Add(msoControlButton, , , , True) '添加新按钮
- .Caption = c.Item(i).Value
- If i = 0 Then .FaceId = myFaceid: .BeginGroup = True
- End With
- Next i
- End If
- '--------------------------------------------------
- .ShowPopup x1, y1
- End With
- End Sub
复制代码
test.zip
(11.38 KB, 下载次数: 425)
|
评分
-
7
查看全部评分
-
|