Outlook - 传递变量以在临时弹出窗口中显示

时间:2017-05-24 05:46:13

标签: vba shell outlook outlook-vba

在Outlook中,我已设置以下代码以临时显示消息。

但是我无法确定如何传递包含要显示的文本的变量(aMessageLabel)。

Sub Test()

    Dim aShell

    Set aShell = CreateObject("WScript.Shell")

    aMessageLabel = Chr(34) & "No Emails to be Forwarded!" & Chr(34)

    aShell.Run "mshta.exe vbscript:close(CreateObject(""WScript.shell"").Popup(aMessageLabel,5,""Message""))"

End Sub

1 个答案:

答案 0 :(得分:0)

这是有效的

Sub Test()

    ' this is the resulting windows command (you can run at command prompt)
    ' mshta.exe vbscript:close(CreateObject("WScript.shell").Popup("No Emails to be Forwarded!",5,"Message"))
    ' the "5" is number of seconds that the popup message will live

    Dim aShell
    Set aShell = CreateObject("WScript.Shell")

    aMessageLabel = "No Emails to be Forwarded!"

    Dim cmd As String

    ' multiline
    cmd = "mshta.exe vbscript:close(CreateObject(""WScript.shell"").Popup("""
    cmd = cmd & aMessageLabel
    cmd = cmd & """,5,""Message""))"
    Debug.Print cmd
    aShell.Run cmd

    ' one line
    aShell.Run "mshta.exe vbscript:close(CreateObject(""WScript.shell"").Popup(""" & aMessageLabel & """,5,""Message""))"

End Sub