Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 273
  • Last Modified:

Copying a PowerPoint slide background gradient's brightness using Insert2 method of VBA

I need to copy the gradient of a slide's background fill from one slide to another.

The properties of the source gradient may be read as follows:

Function ShowGradientProperties(oSld as Slide)
  Dim counter as Integer
  With oSld.Background.Fill.GradientStops
    For counter = 1 to .Count
      Debug.Print counter, .Item(counter).Color
      Debug.Print counter, .Item(counter).Position
      Debug.Print counter, .Item(counter).Transparency
    Next
  End With
End Function

Open in new window


Now, when copying gradient properties, the gradient has to be added first using the GradientStops.Insert method. PowerPoint 2010 added a second Insert2 method which added the Brightness property for each gradient stop.

oSld.Background.Fill.GradientStops.Insert2 RGB, Position, [Transparency], [Index], [Brightness]

Open in new window


But, Brightness is not available in the slide's GradientStops object model so how is it possible to read the source gradient's Brightness?
0
Jamie Garroch
Asked:
Jamie Garroch
1 Solution
 
Rgonzo1971Commented:
Hi,

pls try

      Debug.Print counter, .Item(counter).Color.RGB
      Debug.Print counter, .Item(counter).Color.Brightness
      Debug.Print counter, .Item(counter).Position
      Debug.Print counter, .Item(counter).Transparency

Regards
0
 
Jamie GarrochPowerPoint Consultant & DeveloperAuthor Commented:
That works thank you Rgonzo1971. It's an odd place for the property but it's an odd property because if you set the color and then set the brightness, the color is changed! So, to copy a gradient stop, one first needs to set the brightness of the source stop to 0 before reading the color!
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now