Applying changes to multiple text boxes within a shape for all document shapes

Started by Ahmed1, March 15, 2022, 10:34:30 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ahmed1


I have an issue with the following code, when I run it it only changes the bottom text box font type. However, it changes all text boxes to size 12 pt. Also it only apply the changes to the shapes in the active page, I want it to apply changes to the whole document. Thank you.

Here is the code:

Dim doc             As Visio.Document
Dim pg              As Visio.Page
Dim shpObjs         As Visio.Shapes
Dim shpObj          As Visio.Shape
Dim celObj          As Visio.Cell

Dim i               As Integer

Set shpObjs = ActivePage.Shapes
Set doc = ActiveDocument
For i = 1 To shpObjs.Count
    Set shpObj = shpObjs(i)
    Set celObj = shpObj.Cells("Char.Size")
    celObj.Formula = "=12 pt."
    Set celObj = shpObj.Cells("Char.Font")
    celObj.Formula = "=234"
Next

'Clean up
Set celObj = Nothing
Set shpObj = Nothing
Set shpObjs = Nothing

Surrogate

Hi, please add iteration on pages
Dim doc             As Visio.Document
Dim pg              As Visio.Page
Dim shpObjs         As Visio.Shapes
Dim shpObj          As Visio.Shape
Dim celObj          As Visio.Cell
Set doc = ActiveDocument
Dim i               As Integer
For Each pg in doc.Pages
Set shpObjs = pg.Shapes
For i = 1 To shpObjs.Count
    Set shpObj = shpObjs(i)
    Set celObj = shpObj.Cells("Char.Size")
    celObj.Formula = "=12 pt."
    Set celObj = shpObj.Cells("Char.Font")
    celObj.Formula = "=234"
Next
Next
'Clean
Set doc = Nothing
Set pg = Nothing
Set celObj = Nothing
Set shpObj = Nothing
Set shpObjs = Nothing


PS cross-post finded