powershelloffice-interopvisiopowershell-4.0visio2013

How to hide Visio 2013 when using interop assembly in PowerShell


I'm willing to run Visio 2013 silently through PowerShell. At the moment I use the following code:

Add-Type -Path 'Microsoft.Office.Interop.Visio.dll'

$visio = New-Object Microsoft.Office.Interop.Visio.ApplicationClass
$visio.Visible = $false
$visio.Quit()

The code works but I briefly see the Visio splash screen before it is hidden. I would like to create the application object using Microsoft.Office.Interop.Visio.Application or Microsoft.Office.Interop.Visio.InvisibleApp but I can't find the right syntax.

Any help would be greatly appreciated.


Solution

  • You can try this:

    $visio = New-Object -ComObject Visio.InvisibleApp
    $visio.Quit()
    

    Note that it's not a must to use Add-Type (however you can go also with Add-Type, in this case try Microsoft.Office.Interop.Visio.InvisibleAppClass

    BTW, there is a library for using Visio from PS: https://visioautomation.codeplex.com/