Re: Apply another font to all text boxes within a canvas or to by andreas
andreas
Sun Jun 29 04:38:16 PDT 2008
On 28 Jun., 22:06, Helmut Weber <red....@t-online.de> wrote:
> Hi Andreas,
>
> perhaps like that, and
> watch out for line continuation:
>
> Sub ApplyFontToTextBoxes()
> Dim i As Long ' group items count
> Dim l As Long ' shapes.count
> Dim x As Long ' a shape's index
> Dim y As Long ' a shape's canvas items count
> Dim z As Long ' a shape's canvas item index
> Dim shp As Word.Shape
> l =3D ActiveDocument.Shapes.Count
> For x =3D 1 To l
> =A0 =A0i =3D ActiveDocument.Shapes(x).GroupItems.Count
> =A0 =A0For z =3D 1 To i
> =A0 =A0 =A0 If ActiveDocument.Shapes(x).GroupItems(z). _
> =A0 =A0 =A0 TextFrame.HasText Then
> =A0 =A0 =A0 =A0 =A0ActiveDocument.Shapes(x).GroupItems(z). _
> =A0 =A0 =A0 =A0 =A0TextFrame.TextRange.Font.name =3D "Arial"
> =A0 =A0 =A0 End If
> =A0 =A0Next
> =A0 =A0If ActiveDocument.Shapes(x).TextFrame.HasText Then
> =A0 =A0 =A0 ActiveDocument.Shapes(x).TextFrame. _
> =A0 =A0 =A0 TextRange.Font.name =3D "Arial"
> =A0 =A0End If
> =A0 =A0' ActiveDocument.Shapes(x).Select
> =A0 =A0On Error Resume Next '!
> =A0 =A0y =3D ActiveDocument.Shapes(x).CanvasItems.Count
> =A0 =A0For z =3D 1 To y
> =A0 =A0 =A0 ActiveDocument.Shapes(x).CanvasItems(z). _
> =A0 =A0 =A0 TextFrame.TextRange.Font.name =3D "Arial"
> =A0 =A0Next
> Next
>
> End Sub
> --
>
> Greetings from Bavaria, Germany
>
> Helmut Weber, MVP WordVBA
>
> Vista Small Business, Office XP
Dear Helmut,
as always your macros are running just fine. Thank you very much for
your terrific help.
It is always astonishing how quickly you come up with your solutions.
Best Regards and thank you very much again,
Andreas