小编Edu*_*pos的帖子

如何通过 VBA 显示 Windows 10 通知 Toast

我想知道在 Windows 10 中通过 VBA 显示通知 Toast 的最简单方法。

我没有找到一个好的答案。我在这里找到了一种从 PowerShell 创建通知的非常简单的方法。但我无法让它从 VBA 工作,因为我没有找到一种使用 WScript.Shell 在一行中执行此操作的方法。

我尝试了多种方法来实现这一目标,但没有成功。您可以在下面找到我的最后一次尝试:

Public Sub Notify_Test()

Dim WsShell     As Object: Set WsShell = CreateObject("WScript.Shell")
Dim strCommand  As String

strCommand = """powershell.exe"" ^ "
strCommand = strCommand & "[reflection.assembly]::loadwithpartialname(""System.Windows.Forms"")"
strCommand = strCommand & "; [reflection.assembly]::loadwithpartialname(""System.Drawing"")"
strCommand = strCommand & "; $notify = new-object system.windows.forms.notifyicon"
strCommand = strCommand & "; $notify.icon = [System.Drawing.SystemIcons]::Information"
strCommand = strCommand & "; $notify.visible = $true"
strCommand = strCommand & "; $notify.showballoontip(10,""New …
Run Code Online (Sandbox Code Playgroud)

powershell vba notifyicon

7
推荐指数
1
解决办法
2685
查看次数

标签 统计

notifyicon ×1

powershell ×1

vba ×1