Latest Visio Version not handling VBA changing character size

Started by paulv45, April 20, 2022, 02:10:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

paulv45

My VBA code running forever has stopped working properly.

Anyone else having problems?

Perhaps someone could run this simple experiment that demos the problem on latest Visio version and runs correctly on earlier version.

Visio Version 2203 (Build 15028.20204)
Shape with text:0123456789 30 pt.
Shape sheet 1 character line.
Start recording.
Change 456 to 8 pt.
Stop recording.
Shape sheet 3 characters, 4 3 4, 30 8 30
Use ctrl-z to get back to all 30
Shape sheet back to 1 character line.
Run macro.
Observe all 8 pt.
Shape sheet 1 line 8.


Sub Macro1()

    'Enable diagram services
    Dim DiagramServices As Integer
    DiagramServices = ActiveDocument.DiagramServicesEnabled
    ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150

    Dim UndoScopeID2 As Long
    UndoScopeID2 = Application.BeginUndoScope("Font Size")
    Dim vsoCharacters1 As Visio.Characters
    Set vsoCharacters1 = Application.ActiveWindow.Page.Shapes.ItemFromID(8).Characters
    vsoCharacters1.Begin = 4
    vsoCharacters1.End = 7
    vsoCharacters1.CharProps(visCharacterSize) = 8#
    Application.EndUndoScope UndoScopeID2, True

    'Restore diagram services
    ActiveDocument.DiagramServicesEnabled = DiagramServices

End Sub


***************************

Earlier version works properly.

Visio Version 2108 (Build 14326.20238)
Shape with text:0123456789 30 pt.
Shape sheet 1 character line.
Start recording.
Change 456 to 8 pt.
Stop recording.
Shape sheet 3 characters, 4 3 4, 30 8 30
Use ctrl-z to get back to all 30
Shape sheet back to 1 character line.
Run macro.
Observe correct -- 0123 30 pt, 456 8 pt, 789 30 pt.
Shape sheet 3 characters, 4 3 4, 30 8 30

Recorded macro looks identical to me.


Sub Macro1()

    'Enable diagram services
    Dim DiagramServices As Integer
    DiagramServices = ActiveDocument.DiagramServicesEnabled
    ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150

    Dim UndoScopeID2 As Long
    UndoScopeID2 = Application.BeginUndoScope("Font Size")
    Dim vsoCharacters1 As Visio.Characters
    Set vsoCharacters1 = Application.ActiveWindow.Page.Shapes.ItemFromID(8).Characters
    vsoCharacters1.Begin = 4
    vsoCharacters1.End = 7
    vsoCharacters1.CharProps(visCharacterSize) = 8#
    Application.EndUndoScope UndoScopeID2, True

    'Restore diagram services
    ActiveDocument.DiagramServicesEnabled = DiagramServices

End Sub


Any help greatly appreciated.

Thanks.

Paul

Paul Herber

I've reformatted your code section as it was getting corrupted by the bit that converts ( and : and ) etc into :o and  :-\ etc
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

Yacine

Quote from: Paul Herber on April 20, 2022, 01:31:39 PM
I've reformatted your code section as it was getting corrupted by the bit that converts ( and : and ) etc into :o and  :-\ etc


You killjoy! That was the best part of the post.
Yacine

Yacine

Visio Plan 2

Followed your instructions. Everything looks fine.
What is your point?
Help us helping you.
Yacine

Paul Herber

Quote from: Yacine on April 20, 2022, 01:41:35 PM
Quote from: Paul Herber on April 20, 2022, 01:31:39 PM
I've reformatted your code section as it was getting corrupted by the bit that converts ( and : and ) etc into :o and  :-\ etc


You killjoy! That was the best part of the post.
I qu :-[ e a :( ee, I  :P a k :D j 8)
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

paulv45

Thanks, Paul H.
Yacine -  are you saying you ran experiment on Visio Version 2203 (Build 15028.20204) and did not have a problem?  That is, characters after running macro you recorded were not all 8 pt?

Yacine

Yes but visio Version 2102(Build 13801.21004)
Yacine

vojo

/soapbox

MS continuing to introduce bugs to know good functions and capabilities
Curse of the west coast programmer ;-)

/!soapbox

Surrogate

Quote from: vojo on April 20, 2022, 11:25:04 PMMS continuing to introduce bugs to know good functions and capabilities
Perhaps this is part of a strategy to migrate users of desktop versions of visio to Visio Plan 1 ?  :o

vojo

yea...but all that is is "same bugs / different platform"

It would make more sense if MS wants sunset visio...so they are poisoning usage.
Personally, I would think it would make more sense to add a few things to PPT and then say visio is going EOL

paulv45

Vacine -- what version of Visio is Visio Plan 2 providing you?

Yacine

Build 13801.21004
What are you trying to do anyway?
Why not a proper macro instead of the recorded one?
I suspect a layer 8 error because of the fixed reference to a shape.
Yacine

wapperdude

Running V2019 Pro, Windows 10.  I see the same problem.  Visio doesn't seem to be recognizing the Char.Begin / End settings correctly..  Definitely seems like a new bug.
Visio 2019 Pro

wapperdude

It occurred to me that perhaps the 1st step in the code ought to be setting the chars variable to null before assigning it the shape chars..  Just a thought.
Visio 2019 Pro

wapperdude

Took another look at this... Doing an <f8> step thru the code, it runs fine and provides the expected result.  Running the code, produces the error.  Interestingly, using debug.print does show that Begin / End statements do find the correct location for changes, but for some reason, at normal running, all characters are changed to 8 pt.
Visio 2019 Pro