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.

Jumpy

OK. Problem identified:

The Code was designed to work with shape text, that has only one general CharSize.
I did this because it's easy and it was what I thought was needed for the first resize example.

But it is possible in Visio to give a text different CharSizes for different characters.
Then the Characters Section of the ShapeSheet gets multiple rows, as you can see in the picture I made from one of the shapes in the resize3 example.

As you can see, the code only works for the first row.

How to change that is beneath me at this late hour and maybe tomorrow I have the time to look it up in Graham Wideman's book. Or someone else knows how to do it. I think a character object is needed and has to be manipulated somehow...

Yacine

Yacine

Brandy

You are so right....  :D ;D

It only change the first row... It was driving me crazy..... :'(

I thought it was just me....

Thank you, thank you, thank you....

I know it's late... and thank you for working this out for me...

I need to find a way to apply it to all the rows instead of just the first one....

Again, thank you so much

Brandy


Yacine

#33
Bah, schon wieder eine Tapete ruiniert! ;)
But be careful, Brandy gives you some "you are beautiful" and removes them afterwards, when it doesn't work  ;D.
Yacine

Jumpy

OK, didn't need the charakter object, this shall do the trick:

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
Dim i As Integer

'Change the selected shape
douHeight = shp.Cells("Height").Result("MM")

For i = 0 To shp.Section(3).Count - 1
douCharSize = shp.Section(3).Row(i).Cell(7).Result("pt.")
strFormula = "Height/" & douHeight & " mm *" & douCharSize & " pt."
shp.Section(3).Row(i).Cell(7).Formula = strFormula
Next i


'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
Dim pg As Visio.Page

For Each pg In Application.ActiveDocument.Pages
For Each shp In pg.Shapes
  Change_Formula shp
Next
Next

End Sub

Brandy

Thank you, thank you, thank you

I tried every code in VB to make it loop and nothing worked.  You are wonderful... just wonderful...

I tried the new code / script and it worked on/for some but not all. 

See attachement.

Again, thank you so, so much

Brandy

Brandy

@Yacine,..... that's not true....  :D (Smile).....You are beautiful, just beautiful....  :)

I would like to thank you all from the bottom of my heart for taking the time to help me...

Just wonderful..... just wonderful....

Brandy


Yacine

#37
Try selecting all and set the vertical alignment and the 4 margins (top,bottom,left and right) to the same value.
Yacine

Brandy

#38
See... I still think you are beautiful even if it didn't work....  :) :) :) :)

If I enlarge the shape, everything aligns correctly, but if I reduce the size... everything goes crazy.... "Go figure"....  Just my luck.... :o

See attachment...

Thank you, thank you, thank you...

Brandy

Jumpy

Maybe you could upload the example where it still doesn't function as .vsd again?
The formula resizes the text, accordingly to the height of the subshape, which normaly resizes accordingly to the height of the group.
But there may be formulas in the shape to alter this behaviour and so without seeing the .vsd it would be back to fruitless guessing again.

JuneTheSecond

Take a rest in the Visio Tea Room, every body.  :) :) :) :)
Best Regards,

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

Brandy

#41
Should I restore the formulas in "ShapeSheet" for Text Transform or User-defined?

User.txtw = TEXTWIDTH(TheText) - LeftMargin - RightMargin

or

TexWidth =GUARD(EVALTEXT(TheText)) ..... this didn't work

see attachment

Thanks

Brandy


Jumpy

The problem here seems to be the fixed values in the Tab Section, that is the Tabulators.
When resizing diagonally the shape width and height get smaller "proportional" (german word).
So when the text gets also smaller proportional you have no problem because it always fits in a line, because as the shape's width and so the linewidth gets smaller, the text gets smaller, too and still fits.

But if you have a fixed value for Tabulators the text in a line will at one point stay to big for the width of the shape (and the linewidth) and so you get a linebreak/newline. That you can see for example in that in the left words the spacing between the lines get doubled. Thats because the right words get between them because if the linebreak.

Solution: You have to develop a formula for changing the Tabulator that works the same as for the Charsize.

I can't help with that, because after these lines I close my Laptop and make a prolonged weekend-holiday with my family. Maybe if there is WLan in the holiday flat I will try to help you, but can't promise.

Good luck.

Brandy

I found the problem.... "Tabs".....

I can't believe this... Tabs.... WOW!

Now I need to work on the tab issue..... >:( :o ??? ::) :P

Again, thank you so, so much....

Brandy

PS:  Since I have no clue where you are, I will a drink to night on behalf of everyone helping me.... ... Here to everyone... Thank you, thank you, thank you.....

Brandy

@Jumpy,

I'm so, so sorry, I should have read your posting before I submitted the last entry.

This is what I get for moving too fast....

Next time, I will read everyone's comments before I submit my solution/issue/problem/suggestions/any and every.... :) :)

Thanks

Brandy