title: How to show Windows 10 notification toast from VBA
body: <p>I'd like to know the easiest way to show notification toast in windows 10 from VBA.</p>
  <p>I didn't found a good answer to this. I found a really simple way to create notifications from PowerShell <a href="https://stackoverflow.com/a/42605444/12676192">here</a>. But I can't get it to work from VBA because I didn't find a way to execute this in one line using WScript.Shell.</p>
  <p>I tried several ways to accomplish that but i didn't succeed. Below you can find my last attempt:</p>
  <pre><code>Public Sub Notify_Test()
  
  Dim WsShell     As Object: Set WsShell = CreateObject(&quot;WScript.Shell&quot;)
  Dim strCommand  As String
  
  strCommand = &quot;&quot;&quot;powershell.exe&quot;&quot; ^ &quot;
  strCommand = strCommand &amp; &quot;[reflection.assembly]::loadwithpartialname(&quot;&quot;System.Windows.Forms&quot;&quot;)&quot;
  strCommand = strCommand &amp; &quot;; [reflection.assembly]::loadwithpartialname(&quot;&quot;System.Drawing&quot;&quot;)&quot;
  strCommand = strCommand &amp; &quot;; $notify = new-object system.windows.forms.notifyicon&quot;
  strCommand = strCommand &amp; &quot;; $notify.icon = [System.Drawing.SystemIcons]::Information&quot;
  strCommand = strCommand &amp; &quot;; $notify.visible = $true&quot;
  strCommand = strCommand &amp; &quot;; $notify.showballoontip(10,&quot;&quot;New Chat!&quot;&quot;,&quot;&quot;You have received New Chat!&quot;&quot;,[system.windows.forms.tooltipicon]::None)&quot;
  
  WsShell.Run strCommand
  
  End Sub
  </code></pre>
  <p>I'd like to avoid writing a .ps1 file. Can someone please help me with this question?</p>
  <p>Thank you in advance!</p>
  <p><strong>UPDATE:</strong></p>
  <p>Thanks to @Remko I was able to display the notification.</p>
  <p>I did a function to make its use simpler:</p>
  <pre><code>Public Function Notify(ByVal title As String, ByVal msg As String, _
                      Optional ByVal notification_icon As String = &quot;Info&quot;, _
                      Optional ByVal app As String = &quot;excel&quot;, _
                      Optional ByVal duration As Integer = 10)
                      
  'Parameters:
  '    title (str):Notification title
  '    msg (str):Notification message
  '    notification_icon (str):Notification icon. Available options are: Info, Error and Warning
  '    app (str):Process name of app you want to be display in the system tray icon
  '    duration (int):Duration of notification in seconds
  
  Const PSpath    As String = &quot;powershell.exe&quot;
  
  Dim WsShell     As Object: Set WsShell = CreateObject(&quot;WScript.Shell&quot;)
  Dim strCommand  As String
  
  If notification_icon &lt;&gt; &quot;Info&quot; And notification_icon &lt;&gt; &quot;Error&quot; And notification_icon &lt;&gt; &quot;Warning&quot; Then
      notification_icon = &quot;Info&quot;
  End If
  
  strCommand = &quot;&quot;&quot;&quot; &amp; PSpath &amp; &quot;&quot;&quot; -Command &quot; &amp; Chr(34) &amp; &quot;&amp; { &quot;
  strCommand = strCommand &amp; &quot;Add-Type -AssemblyName 'System.Windows.Forms'&quot;
  strCommand = strCommand &amp; &quot;; $notification = New-Object System.Windows.Forms.NotifyIcon&quot;
  strCommand = strCommand &amp; &quot;; $path = (Get-Process -id (get-process &quot; &amp; app &amp; &quot;).id).Path&quot;
  strCommand = strCommand &amp; &quot;; $notification.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)&quot;
  strCommand = strCommand &amp; &quot;; $notification.BalloonTipIcon  = [System.Windows.Forms.ToolTipIcon]::&quot; &amp; notification_icon &amp; &quot;&quot;
  strCommand = strCommand &amp; &quot;; $notification.BalloonTipText = '&quot; &amp; msg &amp; &quot;'&quot;
  strCommand = strCommand &amp; &quot;; $notification.BalloonTipTitle = '&quot; &amp; title &amp; &quot;'&quot;
  strCommand = strCommand &amp; &quot;; $notification.Visible = $true&quot;
  strCommand = strCommand &amp; &quot;; $notification.ShowBalloonTip(&quot; &amp; duration &amp; &quot;)&quot;
  strCommand = strCommand &amp; &quot; }&quot; &amp; Chr(34)
  
  WsShell.Run strCommand, 0, False
  
  End Function
  
  Public Sub Notify_Examples()
  
  Notify &quot;Insert Title Here&quot;, &quot;Insert Your Message Here&quot;
  Notify &quot;Insert Title Here&quot;, &quot;Insert Your Message Here&quot;, &quot;Warning&quot;
  Notify &quot;Insert Title Here&quot;, &quot;Insert Your Message Here&quot;, &quot;Error&quot;, &quot;outlook&quot;
  
  End Sub
  </code></pre>
  <p>I'd like to make and extra observation. Nothing happens when leave the PSpath = &quot;powershell.exe&quot;. I guess this is due to the fact my user is not an admin. I was able to bypass this by copying the powershell.exe to my documents and altering the PSpath to &quot;C:\Users\my_user\Documents\powershell.exe&quot;. Maybe this is the case for you too...</p>