Solved

Change data label fill texture

Posted on 2013-06-26
1
599 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
Comment Utility
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

People often ask "How do I make this macro run every time I show a new slide or add a new slide etc." This means making PowerPoint respond to that EVENT and, unlike in Excel, it's not that easy! First, I would avoid using the pseudo events left o…
Outline From PowerPoint 2010 it is possible to have shapes appear in front of video, in earlier versions video always played in front of other shapes. This means it is possible to have captions animated to appear in front of video. Users who h…
This video teaches viewers how to fit pictures into slides, crop and remove backgrounds, and alter photos to look more professional.
The viewer will learn how to edit the master slide. They will also learn how to combine multiple themes into one master slide to use them in their presentation.

772 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

12 Experts available now in Live!

Get 1:1 Help Now