I'm receiving an error when trying to create a new Visio document using VisioPs New-VisioDocument.
I can import the module and start Visio without any issue. Where I’m having an issue is I get the following error when trying to open a new Visio document. Not sure what it is looking for.
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
PS C:\Users\ljuhnke> Import-Module VisioPS
PS C:\Users\ljuhnke> New-VisioApplication
PS C:\Users\ljuhnke> New-VisioDocument
__New-VisioDocument : Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface
type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM
component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error:
Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
At line:1 char:1
+ New-VisioDocument
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VisioDocument], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,VisioPS.Commands.New_VisioDocument
PS C:\Users\ljuhnke> Get-Module -All
ModuleType Name ExportedCommands
---------- ---- ----------------
Binary Microsoft.PowerShell.Commands.Ma... {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Binary VisioPS {Close-VisioDocument, Get-VisioPageCell, Get-VisioShapeCell, New-Visi...
Manifest VisioPS {Close-VisioApplication, Close-VisioDocument, Connect-VisioApplicatio...
PS C:\Users\ljuhnke> $PSVersionTable
Name Value
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.296
PSRemotingProtocolVersion 2.2
I haven't been able to figure this out and I'm learning on working with Powershell and not sure what to look for here.
Thank you
Comments: After looking at the error message some more I wonder if it is because the Office 2010 Primary Interop Assemblies are not available. Can you try installing them from here: http://www.microsoft.com/en-us/download/details.aspx?id=3508 And then retry your scenario afterwards
I can import the module and start Visio without any issue. Where I’m having an issue is I get the following error when trying to open a new Visio document. Not sure what it is looking for.
Windows PowerShell
Copyright (C) 2012 Microsoft Corporation. All rights reserved.
PS C:\Users\ljuhnke> Import-Module VisioPS
PS C:\Users\ljuhnke> New-VisioApplication
PS C:\Users\ljuhnke> New-VisioDocument
__New-VisioDocument : Unable to cast COM object of type 'Microsoft.Office.Interop.Visio.ApplicationClass' to interface
type 'Microsoft.Office.Interop.Visio.IVApplication'. This operation failed because the QueryInterface call on the COM
component for the interface with IID '{000D0700-0000-0000-C000-000000000046}' failed due to the following error:
Library not registered. (Exception from HRESULT: 0x8002801D (TYPE_E_LIBNOTREGISTERED)).
At line:1 char:1
+ New-VisioDocument
+ ~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [New-VisioDocument], InvalidCastException
+ FullyQualifiedErrorId : System.InvalidCastException,VisioPS.Commands.New_VisioDocument
PS C:\Users\ljuhnke> Get-Module -All
ModuleType Name ExportedCommands
---------- ---- ----------------
Binary Microsoft.PowerShell.Commands.Ma... {Add-Content, Clear-Content, Clear-ItemProperty, Join-Path...}
Manifest Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Binary VisioPS {Close-VisioDocument, Get-VisioPageCell, Get-VisioShapeCell, New-Visi...
Manifest VisioPS {Close-VisioApplication, Close-VisioDocument, Connect-VisioApplicatio...
PS C:\Users\ljuhnke> $PSVersionTable
Name Value
---- -----
WSManStackVersion 3.0
PSCompatibleVersions {1.0, 2.0, 3.0}
SerializationVersion 1.1.0.1
BuildVersion 6.2.9200.16398
PSVersion 3.0
CLRVersion 4.0.30319.296
PSRemotingProtocolVersion 2.2
I haven't been able to figure this out and I'm learning on working with Powershell and not sure what to look for here.
Thank you
Comments: After looking at the error message some more I wonder if it is because the Office 2010 Primary Interop Assemblies are not available. Can you try installing them from here: http://www.microsoft.com/en-us/download/details.aspx?id=3508 And then retry your scenario afterwards