Author Topic: Code / Formula to represent a Group [resizing text]  (Read 27996 times)

0 Members and 1 Guest are viewing this topic.

Brandy

  • Full Member
  • ***
  • Posts: 91
Code / Formula to represent a Group [resizing text]
« on: May 30, 2010, 10:49:52 AM »
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

  • Hero Member
  • *****
  • Posts: 2698
Re: Code / Formula to represent a Group [resizing text]
« Reply #1 on: May 30, 2010, 12:12:51 PM »
Yacine

Brandy

  • Full Member
  • ***
  • Posts: 91
Re: Code / Formula to represent a Group [resizing text]
« Reply #2 on: May 30, 2010, 05:29:10 PM »
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

  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: Code / Formula to represent a Group [resizing text]
« Reply #3 on: May 30, 2010, 07:57:19 PM »
May be you need to set formulas to all child shapes.  :) :) :) ;) ;) :D :D
Best Regards,

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

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3800
  • Ideas Visio-lized into solutions
Re: Code / Formula to represent a Group [resizing text]
« Reply #4 on: May 30, 2010, 11:23:44 PM »
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

  • Hero Member
  • *****
  • Posts: 2698
Re: Code / Formula to represent a Group [resizing text]
« Reply #5 on: May 31, 2010, 12:00:31 AM »
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

  • Full Member
  • ***
  • Posts: 91
Re: Code / Formula to represent a Group [resizing text]
« Reply #6 on: May 31, 2010, 03:08:06 PM »
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
« Last Edit: May 31, 2010, 03:33:13 PM by Brandy »

Yacine

  • Hero Member
  • *****
  • Posts: 2698
Re: Code / Formula to represent a Group [resizing text]
« Reply #7 on: May 31, 2010, 04:31:39 PM »
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...
« Last Edit: May 31, 2010, 04:37:18 PM by Yacine »
Yacine

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: Code / Formula to represent a Group [resizing text]
« Reply #8 on: May 31, 2010, 04:33:41 PM »
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

Code
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

  • Full Member
  • ***
  • Posts: 91
Re: Code / Formula to represent a Group [resizing text]
« Reply #9 on: May 31, 2010, 06:06:49 PM »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3800
  • Ideas Visio-lized into solutions
Re: Code / Formula to represent a Group [resizing text]
« Reply #10 on: May 31, 2010, 06:59:58 PM »
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

  • Full Member
  • ***
  • Posts: 91
Re: Code / Formula to represent a Group [resizing text]
« Reply #11 on: May 31, 2010, 07:11:01 PM »

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

  • Full Member
  • ***
  • Posts: 91
Re: Code / Formula to represent a Group [resizing text]
« Reply #12 on: May 31, 2010, 07:25:52 PM »
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
« Last Edit: May 31, 2010, 07:43:03 PM by Brandy »

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3800
  • Ideas Visio-lized into solutions
Re: Code / Formula to represent a Group [resizing text]
« Reply #13 on: May 31, 2010, 10:08:21 PM »
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

  • Hero Member
  • *****
  • Posts: 1061
Re: Code / Formula to represent a Group [resizing text]
« Reply #14 on: June 01, 2010, 03:13:28 AM »
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?