?
Solved

Change data label fill texture

Posted on 2013-06-26
1
Medium Priority
?
756 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 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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…
Setting the Scene Animations in PowerPoint are a great tool to convey messages when used carefuly with the content of your slides. There are plenty of animation effects and options, including a Repeat feature for individual animation effects. …
This video teaches viewers how to create handouts from their slides and helps them decide how many slides to include per handout.
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
Suggested Courses

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