I've seen in VBA examples, that partially formatting a Visio shape-text makes use of the characters.begin and characters.end properties to select the part of the text to format.
Now I'm having issues in adapting this to my Powershell script - the begin property seems to be read only:
[DBG]: PS C:\Windows\system32>>> $visioObjects.($_.key).getType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True False ShapeClass System.__ComObject
[DBG]: PS C:\Windows\system32>>> $visioObjects.($_.key).Text
Hello World
[DBG]: PS C:\Windows\system32>>> $visioObjects.($_.key).Characters.Begin
0
[DBG]: PS C:\Windows\system32>>> $visioObjects.($_.key).Characters.End
11
[DBG]: PS C:\Windows\system32>>> $visioObjects.($_.key).Characters.CharCount
11
[DBG]: PS C:\Windows\system32>>> $visioObjects.($_.key).Characters.End = 5
[DBG]: PS C:\Windows\system32>>> $visioObjects.($_.key).Characters.End
11
Here is the code in short for reproduction:
$appVisio = New-Object -ComObject Visio.Application
$docsObj = $appVisio.Documents
$docObj = $docsObj.Add("")
# Set the active page of the document to page 1
$pagsObj = $appVisio.ActiveDocument.Pages
$pagObj = $pagsObj.Item(1)
$shpObj = $pagObj.DrawRectangle(0, 0, 1, 1)
$shpObj.text = 'Hello World'
$shpObj.Characters.Begin = 5 # <======================== Won't accept
$shpObj.Characters.Begin # <======================== Returns 0, makes me cry
Can anyone explain why this is not working?