Code / Formula to represent a Group [resizing text]

Started by Brandy, May 30, 2010, 03:49:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Brandy

Does anyone know and/or have a code/formula that represents a group? 

I need to resize a group of shapes with different text sizes and shapes... I need a code for a group instead of individual shapes. 

A sample is attached...

(just a sample.... if you can resize this group and the text resize with the group, then you have the right code/formula)

Any, any help is greatly appreciated.

Thanks

Brandy

Yacine

Yacine

Brandy

Maybe I'm doing something wrong, because I can't get this to work for a group... It works wonderful for individual shapes, but not groups....

Brandy

JuneTheSecond

May be you need to set formulas to all child shapes.  :) :) :) ;) ;) :D :D
Best Regards,

Junichi Yoda
http://june.minibird.jp/

wapperdude

That's the point.  I believe Brandy is looking for code that pushes the group response down into the sub-shapes.

Wapperdude
Visio 2019 Pro

Yacine

Then you need to access the sub-shapes
http://visguy.com/vgforum/index.php?topic=1621.0

and update their text format related cells - best you record the operation once, then adjust the recorded code to your needs.
Yacine

Brandy

I guess it's just me, but I didn't get the last link.... It does not apply to what I'm trying to do.  

I only need a code to represent a group...

Do you know the code for "Any Digit" "Any Font", or "Any Number"... instead of just 12 pt, because the group has a series of fonts.  

If I enter "Height/3 cm*12pt", it will only maintain the 12 pt, not the 6, 8, 10, 4, etc.

Any, any, any help is greatly appreciated.  I'm running out of time...

Thanks everyone for all your help.

Brandy

Yacine

Brandy,
the sub-shapes need to know what to do - not the group!
You need to tell them how to behave.

I personally purchased a tool called Visiclone. With it, I write the formulas I need in a shape and can then copy it to other shapes. eg the sub-shapes of your group.

Paul Herber has also a nice set of tools, which I believe are even more performant. But I did not really test them yet. Paul, that's your part here...
Yacine

Jumpy

HeHoHeHo,
this post and the previous one are hard to follow, because it seems, that everyone means different things. So I will now happily add my misunderstanding of this topic to the knowledge pool. I wrote some code that replaces every Char.Size with the Formula:
=Height/X mm * Y pt.

where X is the Height and Y the Char.Size of the shape at the time, the code is activated.
I attached the example file, where the code was used successfully, as you can see when resizing.
Hopefully this helps,
Jumpy


Sub Change_Formula(ByVal shp As Visio.Shape)
Dim douHeight As Double
Dim douCharSize As Double
Dim strFormula As String
Dim SubShape As Visio.Shape

'Change the selected shape
douHeight = shp.Cells("Height").Result("MM")
douCharSize = shp.Cells("Char.Size").Result("pt.")
strFormula = "Height/" & douHeight & " mm *" & douCharSize & " pt."

shp.Cells("Char.Size").Formula = strFormula

'Change Sub Shapes by calling this function again
For Each SubShape In shp.Shapes
Change_Formula SubShape
Next

End Sub

'--------------------------------------------------

Sub Start()
'As the name suggests, this Makro has to be started
Dim shp As Visio.Shape

For Each shp In ActivePage.Shapes
Change_Formula shp
Next

End Sub

Brandy

Can I use this in my "ShapeSheet" or I need to copy your script/code into VB?

=Height/X mm * Y pt

Well, I answer my own question, it didn't work...

Thanks

Brandy

wapperdude

Hi Brandy --

I just tried the code, and it worked fine.  The code is a VBA macro.  If you press Alt + F11. you'll open the VBA editor window, and the code resides under Modules.

You can copy this, open your Visio file, open the VBA editor. and paste it in.  (I'm sure there's a more direct way to do this, but this ought to work.)

Wapperdude

Visio 2019 Pro

Brandy


I did the same...  I copied it VB...  I open my diagram, went to VB, and paste the code/script. 

One question, did you do it with the diagram I attached in the previous message? 

That attachment only represents one stencil within my diagram...  I have like 25-50 of those stencils within one diagram...  Take that same diagram and add about 100 more...

I highlighted the group/diagram and paste it into the VB for that particular diagram, then I resized it to test the code and the results indicated that it does not work. 

You have been so wonderful in this dilemma...

Brandy

#12
here's a sample of one of my diagrams

This is after entering all the formulas and codes that was given to me... including the script for VB.

Nothing is working for "Groups" shapes/stencils.

Brandy

wapperdude

Hmmmm.  I just took the file that Jumpy provided.  Set all the character sizes to their default, fixed values.  Duplicated the group.  Ran the code, and everything went fine.

Do you get any error messages, or it simply doesn't work?  You may have some shapes that cause the code to not function.  Haven't looked at the code in detail.

Wapperdude
Visio 2019 Pro

Jumpy

I still think, there is some kind of misunderstanding here.
What do you mean with stencils Brandy? Pages?
What do you mean with Group? Some shapes that are grouped together or a Selection of some shapes?