Macro/VBA to change ALL text block text sizes ?

Started by spyrule, September 20, 2013, 06:08:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

spyrule

Hello,

I've got a large Visio diagram file, that utilizes text blocks quite a bit (for labels essentially), but since I moved to Win7, the font is displaying larger than it should.

So, as a simple solution, I would like to reduce the font pt size of ALL text in the visio document (preferably across all pages) with a specified pt size (or to specify 6pt -> 4pt ).


Yacine

not sure, but I think that activepage holds  all the shapes that you need to access.
so you'd do something like
for each shp in activepage.shapes
  shp.xxx = "12 pt" ' you will get that command from recording a modification of the font size of a shape with macro recorder
next shp
HTH, Y.
Yacine

JohnGoldsmith

If the shapes are based on a master (and the font size still inherits from the master) then you should be able to change the master's font size and see the change reflected in the instance shapes.

The same might be true if the shapes font size inherits from a style, in which case you could adjust the style font size.

If they're not based on a master or have a local value then you'll have to run through the shapes as Yacine suggests.  If that's the case then you might find this helpful:

http://visualsignals.typepad.co.uk/vislog/2007/11/looping-through.html

Hope that helps.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

wapperdude

Another approach might be to change the scale factor for the page.  This affects the shape size but does not affect the font size.

Wapperdude
Visio 2019 Pro

spyrule

Ok,

The only thing I think I can do as a proper solution is to change the actual font specified.

How, do I search for all shapesheet data, character font (64) and replace it with 4 (Calibri) ?

I'm totally newb to VBA for visio, so I can't seem to find information on how to do this.

taken from this thread :
http://visguy.com/vgforum/index.php?topic=581.0

something like :

Sub ChgText()
    Dim vsoPage As Visio.Page, vsoShape As Visio.shape
    Dim vsoCharacters1 As Visio.Characters, vsoStrng As String
   
    For Each vsoPage In ThisDocument.Pages
        For Each vsoShape In vsoPage.Shapes

  '          Set vsoCharacters1 = vsoShape.Characters
  '          vsoCharacters1.Cells = vsoShape.CellsU Char.Font(4)
>>> What is the command to replace the existing char.font(64) with char.Font(4)
        Next
    Next
End Sub


Is there a way to specify the character fontID based on its actual name (not just ID #?) ?

Thanks!

spyrule

So the solution is this :

Public Sub FontChange()
' Change the font of all shapes to 12pt
Dim shpObjs As Visio.Shapes, shpObj As Visio.Shape
Dim i As Integer

Set shpObjs = ActivePage.Shapes
For i = 1 To shpObjs.Count
Set shpObj = shpObjs(i)
' These change the font for the entire page.
'Set celObj = shpObj.Cells("Char.Font")
'celObj.Formula = "4"
' This changes the font Size of all text in the page.
Set celObj = shpObj.Cells("Char.Size")
celObj.Formula = "=12 pt."
Next
End Sub

I got this from :

http://visio.mvps.org/vba/

and modified it to change the font only (see my two commented lines) This worked beautifully.