在 CreateObject("WScript.Shell") 创建的弹出消息框中插入一个新行

Insert a new line in a pop up message box created by CreateObject("WScript.Shell")

抱歉,我花了好几个小时试图找到答案,但还是想不出来。 我尝试使用 vbNewLine 和 vbCrLf,但无法使其在函数和函数调用中工作。

如何使用以下代码添加新行?

试过这个但没用:

checker = MessageTimeOut("Underlying raw data in the workbook has been updated." & vbNewLine & "This will close automatically.", "UPDATE RAW DATA - COMPLETED", 5) 

也尝试过:

checker = MessageTimeOut("Underlying raw data in the workbook has been updated." & vbCrLf & "This will close automatically.", "UPDATE RAW DATA - COMPLETED", 5)

我希望 "This will close automatically." 换行显示。

Function MessageTimeOut(str_message As String, str_title As String, int_seconds As Integer) As Boolean
    Dim Shell
    Set Shell = CreateObject("WScript.Shell")
    Shell.Run "mshta.exe vbscript:close(CreateObject(""WScript.shell"").Popup(""" & str_message & """," & int_seconds & ",""" & str_title & """))"
    MessageTimeOut = True
End Function


Sub Some_Sub()
    ' some lengthy code....
    Dim checker As Boolean
    checker = MessageTimeOut("Underlying raw data in the workbook has been updated. This will close automatically.", "UPDATE RAW DATA - COMPLETED", 5)

编辑:我之前的回答没有使用 mshta,我认为您需要它来使您的消息异步并允许您的代码继续...

这样就可以了:

Sub Test2()

    mshta "Me`s`s`age", "test", 5 '<<< all backticks become newlines

    Debug.Print "This runs right away"

End Sub


Function mshta(ByVal MessageText As String, Optional ByVal Title As String, _
            Optional ByVal PauseTimeSeconds As Integer)

    Dim ConfigString As String, WScriptShell
    Set WScriptShell = CreateObject("WScript.Shell")

    ConfigString = "mshta.exe vbscript:close(CreateObject(""WScript.Shell"").Popup(Replace(""" & MessageText & """,""`"",vbLf)," & PauseTimeSeconds & ",""" & Title & """))"
    WScriptShell.Run ConfigString

End Function