Outlook - Pass variable to be displayed in tempora

2019-09-16 18:24发布

In Outlook I have setup the following code to temporarily display a message.

However I cannot work out how to pass a variable (aMessageLabel) containing the text to be displayed.

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条回答
Anthone
2楼-- · 2019-09-16 19:26

this works

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
查看更多
登录 后发表回答