Solved

Change data label fill texture

Posted on 2013-06-26
1
628 Views
Last Modified: 2013-10-24
I am trying to change the type of fill on a data label in selected graphs in PowerPoint. When I try to change the fill type properties, it returns "Wrong number of arguments or invalid property assignment"

I can't figure out whats wrong...

Private Sub CommandButton1_Click()
    Dim shp As Shape
    Dim cht As Chart

    If ActiveWindow.Selection.ShapeRange.Count > 0 Then
    
        C = ActiveWindow.Selection.ShapeRange.Count
        ReDim Nom_Obj(C + 1)
        For CC = 1 To C
            Nom_Obj(CC) = ActiveWindow.Selection.ShapeRange(CC).Name
        Next CC
        
        For CC = 1 To C
            ActiveWindow.Selection.SlideRange.Shapes.SelectAll
            ActiveWindow.Selection.ShapeRange(Nom_Obj(CC)).Select
            Set shp = ActiveWindow.Selection.SlideRange.Shapes(Nom_Obj(CC))
            
            If (shp.Type = 3) Then
                'graph
                Set cht = shp.Chart
                cht.SeriesCollection(1).ApplyDataLabels
                cht.SeriesCollection(1).DataLabels.Select
                If cht.SeriesCollection(1).DataLabels.Fill.Type = msoFillPatterned Then
                    'BUG HERE
                    cht.SeriesCollection(1).DataLabels.Fill.Type = msosolidfill
                ElseIf cht.SeriesCollection(1).DataLabels.Fill.Type = msosolidfill Then
                    'BUG HERE
                    cht.SeriesCollection(1).DataLabels.Fill.Type = msoFillPatterned
                End If
                cht.SeriesCollection(1).DataLabels.Fill.ForeColor.RGB = RGB(255, 255, 255)
                cht.SeriesCollection(1).DataLabels.Fill.BackColor.RGB = RGB(255, 255, 255)
            End If
            
            Set shp = Nothing
            Set cht = Nothing
            
        Next CC

    End If
End Sub

Open in new window

1.pptx
0
Comment
Question by:theomysh
1 Comment
 
LVL 23

Accepted Solution

by:
JSRWilson earned 500 total points
ID: 39285866
Fill.Type is Read Only

Also note the method to change Forecolor and Backcolor (If they are the same value you wont see a pattern) You need to specify the pattern for a patterned fill.

Try something like this

                If cht.SeriesCollection(1).DataLabels.Format.Fill.Type = msoFillPatterned Then
                    cht.SeriesCollection(1).DataLabels.Format.Fill.Solid
                ElseIf cht.SeriesCollection(1).DataLabels.Format.Fill.Type = msoFillSolid Then
                    cht.SeriesCollection(1).DataLabels.Fill.Patterned (msoPatternDashedHorizontal)
                End If
                cht.SeriesCollection(1).DataLabels.Format.Fill.ForeColor.RGB = RGB(255, 255, 255)
                cht.SeriesCollection(1).DataLabels.Format.Fill.BackColor.RGB = RGB(255, 0, 0)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Most folk recognise that Microsoft Excel, being a numbers-and-formulae-centric application attracts programmers due to the natural fit in mindset. Conversly, when opening Microsoft's dominant presentation creative application, few consider what…
Introduction In all recent versions of PowerPoint it is possible to trigger animations. This means the animation takes place when a certain shape is clicked. This allows you to run animation “on demand” and outwith the normal sequence of mouse cl…
This video teaches viewers how to add transitions to their Slideshows and how to set up timing for the transitions.
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.

770 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