Running the macro recorder using the Format Painter generates no code

Started by Visisthebest, July 21, 2020, 03:14:45 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Visisthebest

I am trying to find out how to programmatically copy the styles (colors/gradients) from one shape to another, but when I run the macro recorder and do a copy-paste of styles from one shape to the next, the macro recorder generates no code other than this boilerplate code:

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

    'Restore diagram services
    ActiveDocument.DiagramServicesEnabled = DiagramServices

Any idea of how to copy over style settings from one shape to the next? Thank you for your help and advice!

Visio 2021 Professional

Surrogate

You are right, not all actions can be write with macro recorder!

Do you use visio's build-in 'Styles'?

Or just want make few shapes same?

Visisthebest

I want to give users some options with respect to styles on subshapes in shapes in the stencil I made.

My idea was to store a few hidden shapes with different styles (that I use to paste style to the subshape in the master shapes I use), if the user chooses a different style I copy the relevant stencil master in to the document stencil then apply the chosen style to the subshape in this master then drop this master from the document stencil on to the page. The copy-paste styles would be ideal, minimum amount of code!
Visio 2021 Professional

Surrogate

I create custom style named 'ololo' this simple code apply change style for selected shape
Dim sh As Shape
Set sh = ActiveWindow.Selection.PrimaryItem
sh.FillStyle = "Ololo"
sh.LineStyle = "Ololo"
sh.TextStyle = "Guide"

But only old-school Visio users remember about Styles!



Surrogate

My answer in thread about Styles in Visio
Quote from: Can't create a new styleIf you use Visio 2016/2019 or Visio Online Plan 2 you can write letters 'def' in field 'Tell me what do you want to do'

If you use Visio 2010/2013 look at answer in that thread in SuperUser forum.


In 'Define style' window you must enter some name for your style and after that you must press button 'Add'

Visisthebest

Thank you Surrogate this is exactly what I'm looking for! Why are so many Visio goodies hidden from users by default?
Visio 2021 Professional

Visisthebest

Visio 2021 Professional

Surrogate

Quote from: Visisthebest on July 22, 2020, 09:04:46 AM
Why are so many Visio goodies hidden from users by default?
IMHO two reasons:
1. Ribbon interface need space more than Classic interface, because there is large and middle-size buttons. For example when you activate all toolbars in Visio 2003, it contain only little icons.

2. MS mean that all these hidden goodies are obsolete !

Surrogate

Quote from: Visisthebest on July 22, 2020, 09:05:52 AM
Can I store styles in a stencil?
Yes, you can distribute your custom styles with stencils.
If you store shapes with custom styles in stencil. After when you drop masters from stencil which use custom style, this action add copy of this style to target Visio document!

Visisthebest

Ok great so added automatically when a master uses a style! :)
Visio 2021 Professional