macro to set shape style

Started by ToninoS, October 26, 2020, 07:36:06 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ToninoS

Hi all, does anyone know if it is possible to either:
1) have a shape change style based on shape data input for the shape that matches name of  or if not
2) have a shape or all shapes in a drawing change style based on a macro that looks at shape data?
Cheers all :)

Surrogate

Quote from: ToninoS on October 26, 2020, 07:36:06 AM
1) have a shape change style based on shape data input for the shape that matches name of  or if not
This code add to ShapeData row with list of styles which used in this document.
Sub AddStyleListToShape1()
Dim st As Style, stn As String, sh As Shape, nnn As String
stn = ""
For Each st In ThisDocument.Styles
stn = stn & ";" & st.Name
Next
Set sh = ActivePage.Shapes(1)
If Not sh.SectionExists(visSectionProp, visExistsAnywhere) Then
sh.AddSection visSectionProp ' add Shape Data section
sh.AddRow visSectionProp, 0, 0 ' add new row to Shape Data
sh.Cells("prop.row_1.type").FormulaU = 1 ' make fixed style list
sh.Cells("prop.row_1.format").FormulaU = Chr(34) & stn & Chr(34)
sh.Cells("prop.row_1.value").FormulaU = "INDEX(1,Prop.Row_1.Format)"
End If
End Sub

ToninoS

#2
Surrogate, thank you :) which column would i try this in? or would this go in VBA for the sheet?

Surrogate

Hi, Tonino !
Please try my attached document.
1. select shape
2. start macro AddStyleListToShape1 for update styles list for document (at my side i have Style names in Russian language)
3. change shape data and check used styles

ToninoS

HEY, that is great, thank you for that Surrogate :)    i can find my way through excel VBA but visio is another beast it seams :)