P
Pista
I have the following function:
Private Function ReAut(root As Object)
Dim shpsObj As Visio.Shapes
Dim shpObj As Visio.Shape
Dim trebuchetMS As Double
Dim courierNew As Double
Set shpsObj = root.Shapes
For Each shpObj In shpsObj
trebuchetMS = ActiveDocument.Fonts("Trebuchet MS").Index
courierNew = ActiveDocument.Fonts("Courier New").Index
If shpObj.Type = visTypeGroup Then
For j = 0 To 20 Step 1 'zatial neviem zistit pocet stlpcov v
sekcii charakter, tak tam davam napevno 20
If shpObj.CellsSRCExists(visSectionCharacter, j,
visCharacterFont, 1) Then
If shpObj.CellsSRC(visSectionCharacter, j,
visCharacterFont).Result("") <> courierNew Then
shpObj.CellsSRC(visSectionCharacter, j,
visCharacterFont).FormulaForceU = trebuchetMS
End If
Else
Exit For
End If
Next j
ReAut = ReAut(shpObj)
Else
For k = 0 To 20 Step 1 'zatial neviem zistit pocet stlpcov v
sekcii charakter, tak tam davam napevno 20
If shpObj.CellsSRCExists(visSectionCharacter, k,
visCharacterFont, 1) Then
If shpObj.CellsSRC(visSectionCharacter, k,
visCharacterFont).Result("") <> courierNew Then
shpObj.CellsSRC(visSectionCharacter, k,
visCharacterFont).FormulaForceU = trebuchetMS
End If
Else
Exit For
End If
Next k
End If
Next
ReAut = 0
End Function
I have used it in a UserForm (I have created an Open Directory dialog there
to select the source directory for all my Visio documents).
So my macro would change the font to Trebuchet MS in all shapes and in all
files in my selected directory.
I have 6 files, but I get for example 4 files "trebuchetized" well, but 2
files wrong. I have no idea, what's wrong, but I've found out an interesting
thing - if I change trebuchetMS = ActiveDocument.Fonts("Trebuchet MS").Index
to trebuchetMS = 176 (I took it from the ShapeSheet of text with font
trebuchet-MS), it works for the other 2 files, but corrupts first 4 files
Thank for your help!
Pista
Private Function ReAut(root As Object)
Dim shpsObj As Visio.Shapes
Dim shpObj As Visio.Shape
Dim trebuchetMS As Double
Dim courierNew As Double
Set shpsObj = root.Shapes
For Each shpObj In shpsObj
trebuchetMS = ActiveDocument.Fonts("Trebuchet MS").Index
courierNew = ActiveDocument.Fonts("Courier New").Index
If shpObj.Type = visTypeGroup Then
For j = 0 To 20 Step 1 'zatial neviem zistit pocet stlpcov v
sekcii charakter, tak tam davam napevno 20
If shpObj.CellsSRCExists(visSectionCharacter, j,
visCharacterFont, 1) Then
If shpObj.CellsSRC(visSectionCharacter, j,
visCharacterFont).Result("") <> courierNew Then
shpObj.CellsSRC(visSectionCharacter, j,
visCharacterFont).FormulaForceU = trebuchetMS
End If
Else
Exit For
End If
Next j
ReAut = ReAut(shpObj)
Else
For k = 0 To 20 Step 1 'zatial neviem zistit pocet stlpcov v
sekcii charakter, tak tam davam napevno 20
If shpObj.CellsSRCExists(visSectionCharacter, k,
visCharacterFont, 1) Then
If shpObj.CellsSRC(visSectionCharacter, k,
visCharacterFont).Result("") <> courierNew Then
shpObj.CellsSRC(visSectionCharacter, k,
visCharacterFont).FormulaForceU = trebuchetMS
End If
Else
Exit For
End If
Next k
End If
Next
ReAut = 0
End Function
I have used it in a UserForm (I have created an Open Directory dialog there
to select the source directory for all my Visio documents).
So my macro would change the font to Trebuchet MS in all shapes and in all
files in my selected directory.
I have 6 files, but I get for example 4 files "trebuchetized" well, but 2
files wrong. I have no idea, what's wrong, but I've found out an interesting
thing - if I change trebuchetMS = ActiveDocument.Fonts("Trebuchet MS").Index
to trebuchetMS = 176 (I took it from the ShapeSheet of text with font
trebuchet-MS), it works for the other 2 files, but corrupts first 4 files
Thank for your help!
Pista