Translate

2013年6月19日 星期三

[VBA] Control the use of 'MsgBox' for automation

https://github.com/walter426/VbaUtilities/blob/master/General%20Utilities.bas

In my code, "MsgBox" is always replaced by "ShowMsgBox" which was written by me.
It is because the running VBA program will be held by the "MsgBox" dialog, so any automation cannot be executed.
Therefore, i need below codes insered in the "General Utilites" to control the prompt of the MsgBox dialog


Public NotShowMsgBox As Boolean

Public Function EnableMsgBox()
    NotShowMsgBox = False
End Function

Public Function DisableMsgBox()
    NotShowMsgBox = True
End Function

Public Function ShowMsgBox(str As String, Optional ByVal Buttons As Integer = vbOKOnly, Optional ByVal Title As Variant = Nothing) As Boolean
    
    If NotShowMsgBox = False Then
        Call MsgBox(str, Buttons, Title)
    End If
    
    ShowMsgBox = NotShowMsgBox
    
End Function

沒有留言:

張貼留言