Solved

Change data label fill texture

Posted on 2013-06-26
1
720 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction I recently received a question about the creation of Computer-Based Training (CBT) that incorporates quizzes in the middle of the lesson. The intent was to keep people engaged in the content, and not to actually track students’ scores.…
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…
The viewer will learn how to edit animations within the presentation, incorporate sound, and set everything up with timing.
The viewer will learn how to edit text. This includes Font, Spacing, Resizing, Color, and other special text options.

690 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