网站大量收购独家精品文档,联系QQ:2885784924

第7章使用对话框代码【超实用VBA】.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第7章使用对话框代码【超实用VBA】

第7章 使用对话框 范例113 使用Msgbox函数显示消息框 Sub Mymsg() Dim Mymsg As Integer Mymsg = MsgBox(文件即将关闭,是否保存所作的修改?, vbYesNoCancel + vbQuestion) Select Case Mymsg Case vbYes ThisWorkbook.Save Case vbNo ThisWorkbook.Saved = True Case vbCancel Exit Sub End Select ThisWorkbook.Close End Sub 范例114 自动关闭的消息框 114-1 使用WshShell.Popup方法显示消息框 Sub AutoClose() Dim MyShell As Object Set MyShell = CreateObject(Wscript.Shell) MyShell.Popup 程序已执行完毕!, 2, 运行提示, 64 Set MyShell = Nothing End Sub 114-2 使用API函数显示消息框 Public Declare Function SetTimer Lib user32 (ByVal hWnd As Long, ByVal nIDEvent As Long, ByVal uElaspe As Long, ByVal lpTimerFunc As Long) As Long Public Declare Function KillTimer Lib user32 (ByVal hWnd As Long, ByVal nIDEvent As Long) As Long Dim MyTimer As Long Sub AutoClose() MyTimer = SetTimer(0, 0, 2000, AddressOf CloseMsg) MsgBox 程序已执行完毕!, 64 End Sub Sub CloseMsg(ByVal hWnd As Long, ByVal uMsg As Long, ByVal idevent As Long, ByVal Systime As Long) Application.SendKeys ~, True KillTimer 0, MyTimer End Sub 范例115 使用InputBox函数输入数据 Sub MyInput() Dim Str As String Str = InputBox(prompt:=请输入数据:) If Len(Trim(Str)) 0 Then Cells(Rows.Count, 1).End(xlUp).Offset(1, 0) = Str End If End Sub Public Declare Function FindWindow Lib user32 Alias FindWindowA (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Public Declare Function FindWindowEx Lib user32 Alias FindWindowExA (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Public Declare Function SendMessage Lib user32 Alias SendMessageA (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Public Declare Function timeSetEvent Lib winmm.dll (ByVal uDelay As Long, ByVal uResolution As Long, ByVal lpFunction As Long, ByVal dwUser As Long, ByVal uFlags As Long) As Long Public Declare Function timeKillEvent Lib winmm.dll (By

文档评论(0)

xy88118 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档