Author Topic: Latest Visio Version not handling VBA changing character size  (Read 7873 times)

0 Members and 1 Guest are viewing this topic.

paulv45

  • Jr. Member
  • **
  • Posts: 52
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.

Code
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.

Code
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
« Last Edit: April 20, 2022, 08:14:28 AM by Paul Herber »

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3360
    • Paul Herber's website
Re: Latest Visio Version not handling VBA changing character size
« Reply #1 on: April 20, 2022, 08:31:39 AM »
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 and applications for Visio -

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

Yacine

  • Hero Member
  • *****
  • Posts: 3163
Re: Latest Visio Version not handling VBA changing character size
« Reply #2 on: April 20, 2022, 08:41:35 AM »
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

  • Hero Member
  • *****
  • Posts: 3163
Re: Latest Visio Version not handling VBA changing character size
« Reply #3 on: April 20, 2022, 09:45:12 AM »
Visio Plan 2

Followed your instructions. Everything looks fine.
What is your point?
Help us helping you.
« Last Edit: April 20, 2022, 12:13:51 PM by Yacine »
Yacine

Paul Herber

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3360
    • Paul Herber's website
Re: Latest Visio Version not handling VBA changing character size
« Reply #4 on: April 20, 2022, 10:37:52 AM »
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 and applications for Visio -

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

paulv45

  • Jr. Member
  • **
  • Posts: 52
Re: Latest Visio Version not handling VBA changing character size
« Reply #5 on: April 20, 2022, 04:40:24 PM »
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

  • Hero Member
  • *****
  • Posts: 3163
Re: Latest Visio Version not handling VBA changing character size
« Reply #6 on: April 20, 2022, 05:17:54 PM »
Yes but visio Version 2102(Build 13801.21004)
« Last Edit: April 21, 2022, 01:14:47 AM by Yacine »
Yacine

vojo

  • Hero Member
  • *****
  • Posts: 1708
Re: Latest Visio Version not handling VBA changing character size
« Reply #7 on: April 20, 2022, 06:25:04 PM »
/soapbox

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

/!soapbox

Surrogate

  • Hero Member
  • *****
  • Posts: 1782
    • ShapeSheet™ Knowledge Base
Re: Latest Visio Version not handling VBA changing character size
« Reply #8 on: April 21, 2022, 01:42:47 AM »
MS 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

  • Hero Member
  • *****
  • Posts: 1708
Re: Latest Visio Version not handling VBA changing character size
« Reply #9 on: April 21, 2022, 07:27:17 AM »
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

  • Jr. Member
  • **
  • Posts: 52
Re: Latest Visio Version not handling VBA changing character size
« Reply #10 on: April 21, 2022, 01:16:00 PM »
Vacine -- what version of Visio is Visio Plan 2 providing you?

Yacine

  • Hero Member
  • *****
  • Posts: 3163
Re: Latest Visio Version not handling VBA changing character size
« Reply #11 on: April 21, 2022, 02:33:11 PM »
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.
« Last Edit: April 22, 2022, 12:59:57 AM by Yacine »
Yacine

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4745
  • Ideas Visio-lized into solutions
Re: Latest Visio Version not handling VBA changing character size
« Reply #12 on: April 22, 2022, 01:11:43 AM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4745
  • Ideas Visio-lized into solutions
Re: Latest Visio Version not handling VBA changing character size
« Reply #13 on: April 22, 2022, 01:57:26 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 4745
  • Ideas Visio-lized into solutions
Re: Latest Visio Version not handling VBA changing character size
« Reply #14 on: April 23, 2022, 12:25:31 AM »
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