Link to home
Start Free TrialLog in
Avatar of NicBrambles
NicBramblesFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Changes to some VB script which inserts WordArt

I have some code which inserts WordArt into excel.  I have tried to change the format of the wordart and it only applies to the first insertion.  I can see why it is doing that but do not know how to change it so that all the inserts are shaded...

I am really new to VB so any help would be much appreciated.
Thanks
 
For rw = 6 To ActiveSheet.UsedRange.Cells(ActiveSheet.UsedRange.Cells.Count).Row Step 20
            Set NewWordArt = ActiveSheet.Shapes.AddTextEffect( _
                PresetTextEffect:=msoTextEffect1, Text:="Generic", _
                FontName:="Arial Black", FontSize:=50, _
                FontBold:=msoFalse, FontItalic:=msoFalse, Left:=ActiveSheet.Range("B" & rw).Left, _
                Top:=ActiveSheet.Range("B" & rw).Top)
             
            With ActiveSheet.Shapes("WordArt 1").Select
                Selection.ShapeRange.Fill.Visible = msoTrue
                Selection.ShapeRange.Fill.Solid
                Selection.ShapeRange.Fill.ForeColor.SchemeColor = 22
                Selection.ShapeRange.Fill.Transparency = 0.6
                Selection.ShapeRange.Line.Weight = 0.25
                Selection.ShapeRange.Line.DashStyle = msoLineSolid
                Selection.ShapeRange.Line.Style = msoLineSingle
                Selection.ShapeRange.Line.Transparency = 1#
                Selection.ShapeRange.Line.Visible = msoTrue
                Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
                Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
            End With

Open in new window

Avatar of shekharsom
shekharsom

use foreach statement:

following is a sample code

Dim sh As Shape

For Each sh In ActiveSheet.Shapes
    If sh.Type = msoFormControl Then
        If sh.FormControlType = xlButtonControl Then
            sh.Visible = Not sh.Visible
        End If
    End If
Next sh

change the controltype to wordart type.
ASKER CERTIFIED SOLUTION
Avatar of Rory Archibald
Rory Archibald
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of NicBrambles

ASKER

That's perfect thank you.