Outlook - Pass variable to be displayed in temporary Popup

假装没事ソ 提交于 2020-03-27 07:12:25

问题


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:


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


来源:https://stackoverflow.com/questions/44149929/outlook-pass-variable-to-be-displayed-in-temporary-popup

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