【问题标题】:Outlook - Pass variable to be displayed in temporary PopupOutlook - 传递变量以显示在临时弹出窗口中
【发布时间】:2017-05-24 05:46:12
【问题描述】:

在 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) 你想从哪里传递消息?谁或什么人知道不转发任何电子邮件? (2) 为什么不使用 VBA 的 MsgBox 来显示消息?您可能有充分的理由,但您的问题并不明显。
  • 2.我会将宏设置为每十分钟运行一次,并希望弹出一个窗口告诉用户宏正在运行,如果他们当时恰好在 Outlook 中工作。
  • 1.如果我使用的是普通消息框,那么 Msgbox aMessageLabel 会给我一个弹出窗口,上面写着“没有要转发的电子邮件”,但是当我运行上面的代码时,弹出窗口是空白的。

标签: vba shell outlook


【解决方案1】:

这行得通

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

【讨论】:

  • 我已经更新了我的宏并且弹出窗口出现和消失了相关的文字,谢谢你的帮助!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-02-05
  • 1970-01-01
  • 1970-01-01
  • 2013-04-12
  • 2017-11-28
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多