Solved

Changes to some VB script which inserts WordArt

Posted on 2008-06-20
3
562 Views
Last Modified: 2010-04-21
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

0
Comment
Question by:NicBrambles
3 Comments
 
LVL 4

Expert Comment

by:shekharsom
ID: 21830123
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.
0
 
LVL 85

Accepted Solution

by:
Rory Archibald earned 400 total points
ID: 21830797
Try this:

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 newwordart

               With .Fill

                  .Visible = msoTrue

                  .Solid

                  .ForeColor.SchemeColor = 22

                  .Transparency = 0.6

               End With

               With .Line

                  .Weight = 0.25

                  .DashStyle = msoLineSolid

                  .Style = msoLineSingle

                  .Transparency = 1#

                  .Visible = msoTrue

                  .ForeColor.RGB = RGB(0, 0, 0)

                  .BackColor.RGB = RGB(255, 255, 255)

               End With

            End With

Open in new window

0
 

Author Closing Comment

by:NicBrambles
ID: 31469080
That's perfect thank you.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Hiding column macro 10 28
Office 2016 Excel Issue 4 26
VBScript Issues 8 15
How do I crate a Pivot table in Excel 2 10
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

896 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now