Text outside of shape/box. Change text box margin

Started by arvid1337, December 22, 2021, 09:11:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

arvid1337

Hello,

I have problems with text that appears outside of my shape.

I found that I could change the text block margin/format using the shapesheet data and editing the margin of the text box.

However, I have over 100 shapes that I want to do this on.

Can I somehow code/macro this event?

I want to change the properties of the selected shape/object.

How?

I can get some images if my description is unclear.

Surrogate


arvid1337

Shape, I think.

It's a regular rectangle with text inside.

Surrogate

Try this code fo single selected shapeDim sh As Shape
Set sh = ActiveWindow.Selection.PrimaryItem
With sh
    .CellsSRC(visSectionObject, visRowTextXForm, visXFormPinY).FormulaU = "Height"
    .CellsSRC(visSectionObject, visRowTextXForm, visXFormHeight).FormulaU = "10 mm"
    .CellsSRC(visSectionObject, visRowTextXForm, visXFormLocPinY).FormulaU = "TxtHeight*0"
    .CellsSRC(visSectionObject, visRowTextXForm, visXFormWidth).FormulaU = "Width"
    .CellsSRC(visSectionObject, visRowTextXForm, visXFormPinX).FormulaU = "Width*0.5"
    .CellsSRC(visSectionObject, visRowTextXForm, visXFormLocPinX).FormulaU = "TxtWidth*0.5"
    .CellsSRC(visSectionObject, visRowTextXForm, visXFormAngle).FormulaU = "0 deg"
End With

miless2111s

Can you select all the items to be changed at once?  For instance are they on a layer so that you can select / type / layer / select the relevant layer?

I use a macro that came from here originally: [url]http://visguy.com/vgforum/index.php?topic=4843.0[/url.

Sub change_shapesheet()
'// Set the ShapeSheet formula for each selected cell. Note, all
'// selected shapes must actually have the cells!

Dim shp As Visio.Shape
For Each shp In Visio.ActiveWindow.Selection

     '// Add cell and formula/results here:
     shp.Cells("Char.Color").FormulaForceU = "=IF(SQRT(0.241*RED(FillBkgnd)^2+0.691*GREEN(FillBkgnd)^2+0.068*BLUE(FillBkgnd)^2)<130,RGB(255,255,255),RGB(0,0,0))"
     
     'shp.Cells("Char.Color").FormulaU = 2 '//...IU = inches
     'shp.Cells("Prop.CommieSize").Result("mm") = 2 * 25.4
     'shp.Cells("Prop.Name").FormulaU = Chr(34) & "Bob" & Chr(34)
     'shp.CellsU("Width").FormulaForceU = "GUARD(Width * 2)" '//...'Force' to override preexisting GUARDs

Next shp
Set shp = Nothing
End Sub


To use this first enter the macro, adjust what is being changed, then select all the items to be changed and trigger the macro.

Note that if you wan to  have text in the cell rather than a forumla we still use forumla setting however have to have triple quotes for each quote needed such as:
     shp.Cells("Prop.Row_6.Label").FormulaU = """Hyperlink"""
     shp.Cells("Prop.Row_6.Prompt").FormulaU = """Address of hyperlink"""
     shp.Cells("Prop.Row_6.Value").FormulaU = "=Hyperlink.Row_1.Address"
     shp.Cells("Prop.BeginX.Invisible").FormulaU = "=TRUE"

I hope this helps :)