Visio PowerShell 4.7.0
Headline change: typed setters on CustomPropertyCells / UserDefinedCellCells plus a friendly diagnostic on bad formulas, closing the long-running thread that started with #117. Plus an audit-pass making Get-* cmdlets' positional bindings consistent across the module.
Added
-
Typed setters on
CustomPropertyCellsandUserDefinedCellCellsfor setting cell values without having to think about Visio's formula encoding. Each setter writes a correctly-encoded Visio formula and (where applicable) sets theTypecell to match. From PowerShell:$cp = New-Object VisioAutomation.Shapes.CustomPropertyCells $cp.SetString("hello") # Type=0 (String) $cp.SetNumber(42) # Type=2 (Number) $cp.SetBool($true) # Type=3 (Boolean) $cp.SetDate([datetime]::Now) # Type=5 (Date) $cp.SetFormula("=...") # raw escape hatch
UserDefinedCellCellsexposesSetStringandSetFormula. The setters become the recommended replacement for raw$cells.Formula = ...assignment. Closes #144. -
Formulaproperty onCustomPropertyCellsandUserDefinedCellCellsas the canonical name (renamed fromValueto surface that the cell stores a Visio formula, not a literal value).
Deprecated
CustomPropertyCells.ValueandUserDefinedCellCells.Valueare now[Obsolete]aliases forFormula. Existing PowerShell scripts that read or write$cells.Valuekeep working unchanged through the deprecation window. Migration: rename$cells.Valueto$cells.Formula, or use the new typed setters. Part of #144.
Fixed
Get-VisioShapenow declares an explicitDefaultParameterSetName = "shapebyname". Previously a no-argsGet-VisioShapecall relied on PowerShell nondeterministically picking a parameter set; under stricter PowerShell configurations it could throwAmbiguousParameterSet. Closes #130.Get-VisioLockCellsnow callsWriteObject(dic)instead ofWriteObject(dic, true), matching its sibling "Get a dictionary keyed by shape" cmdlets. Pure consistency fix; observable behavior is unchanged. Closes #129.
Changed
Set-VisioCustomPropertywith a manually-constructedCustomPropertyCellsvia-Cellsnow surfaces anArgumentExceptionwith a self-explanatory message pointing at the new typed setters when theFormulafield is set to a raw string. Previously this path raised an opaqueCOMException: #NAME?from the underlying COM call. The defaultSet-VisioCustomProperty -Value "x"flow is unaffected (the cmdlet pre-encodes internally). Part of #144.- Get- cmdlet positional parameters — full audit pass.* Eleven
Get-*cmdlets gain consistent positional bindings so the natural shorthand forms (Get-VisioPage "Page-1" $doc,Get-VisioCustomProperty $shape, etc.) work as users intuit. The convention adopted: cmdlets with both-Nameand a single object context have-Nameat position 0 and the object (-Document/-Page) at position 1; cmdlets with just an object context have it at position 0. Closes #143 (and supersedes the narrower #142). Get-VisioMaster—-Documentparameter is now positional, so the natural formGet-VisioMaster "Group" $docworks as users intuit. Closes #142.
Install
Install-Module VisioThe module ships from the Visio package on the PowerShell Gallery. Bundled .NET DLLs include the underlying VisioAutomation library plus Microsoft.Msagl and GenTreeOps.
Related
- The bundled VisioAutomation NuGet is the underlying .NET library this module wraps.
- Project documentation — guides and per-cmdlet reference.
- Custom properties page — covers the new typed setters with a per-Type behavior matrix.
- Full changelog.