PPT.ColorFormat.Brightness in MS PowerPoint 2010 to Add and Format Shapes in VB.NET
In this article I am going to explain about how to select the first slide in a Microsoft PowerPoint 2010 presentation, add a shape to it, and then change the brightness of the shape's foreground.
Introduction
In this article I am going to explain about how to select the first slide in a Microsoft PowerPoint 2010 presentation, add a shape to it, and then change the brightness of the shape's foreground. For this we use PPT.ColorFormat.Brightness in Microsoft PowerPoint 2010.
Microsoft Office 2010 offer some powerful tools, using this tools you can create application. Using Microsoft Visual Basic for Applications (VBA) you can create your own application according to your need. These application can performer some specific task.
For creating application we can use
- VBA host of Excel 2010
- VBA host of PowerPoint 2010
- VBA host of Word 2010
NOTE : OneNote 2010 is not a VBA host.
Code that we use in this application are given below
Sub TestBrightness()
Dim a As Integer
Dim b As Shape
Dim c As Slide
c = ActivePresentation.Slides(1)
' Add a new shape: A 200x100 pixel balloon, and set its color:
b = c.Shapes.AddShape(msoShapeBalloon, 10, 10, 200, 100)
b.Fill.ForeColor.RGB = 3487637
For a = 0 To 100
SetBrightness(b, i / 100)
' Wait 1/10 second or so.
Pause(0.1)
Next a
End Sub
Sub SetBrightness(b As Shape, brightnessValue As Single)
Dim cf As ColorFormat
cf = b.Fill.ForeColor
cf.Brightness = brightnessValue
End Sub
Function Pause(numberOfSeconds As Object)
Dim startTime, endTime As Object
startTime = Timer
endTime = startTime + numberOfSeconds
Do While Timer < endTime
DoEvents()
Loop
End Function
Step for creating Application
Step 1 : Start Microsoft PowerPoint 2010 :
Step 2 : Using Alt + F11 Key Start Visual Basic for Applications (VBA) Window :
Step 3 : Select on VBAProject(Presentation 1) :
Step 4 : Right Click On VBAProject(Presentation 1) ==> Goto Insert==> Goto Module & click on Module:
Step 5 : Write Code in Visual Basic for Applications (VBA) Window :
Step 6 : Run Application using F5 :
Step 7 : Macros window will open, Select Macros name and click on Run Button :
Step 8 : Output of Application :