Deactivate msgbox in a sub VBA

爷,独闯天下 提交于 2021-02-19 07:47:27

问题


Sub prelim()
    MsgboX "Hello World"
End Sub


Sub Main()
    Call prelim
End Sub

In the above code Sub prelim can't be edited.I want msgbox when I run Sub prelim but when I run Sub Main I don't want the message box to get popped out. How to do it?


回答1:


This is not possible without changing Sub prelim

Sub prelim(Optional silent As Boolean = True)
    If Not silent Then MsgBox "Hello World"
End Sub


Sub Main()
    prelim True   'no msgbox
    prelim False  'with msgbox
    prelim        'no msgbx
End Sub


来源:https://stackoverflow.com/questions/46115555/deactivate-msgbox-in-a-sub-vba

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!