I'm trying to make text in the data label of the chart with shadow effect (that shadow effect which you have at top of the PowerPoint menu), but I'm unable to make it work, dataLabels.shadow or dataLabels.font.shadow makes the frame shadowed, not the text.
I was googling a lot, I have found out this could be possible via TextFormat or TextFormat2 property, unfortunately I'm not able to access it for the text in the data label anyhow. My current code, lines after comment does not work:
For Each Shape In Slide.Shapes
If Shape.HasChart Then
Dim i As Integer
Dim v As Variant
Set pts = Shape.Chart.SeriesCollection(1).Points
For Each s In Shape.Chart.SeriesCollection
v = s.Values
If s.Name <> "XXX_XXX" Then
If v(pts.Count) >= 0.05 Then
s.Select
s.Points(pts.Count).Select
s.Points(pts.Count).ApplyDataLabels
s.DataLabels.Font.Color = s.Border.Color
s.DataLabels.Font.Size = 20
s.DataLabels.Font.Name = "Calibri"
's.DataLabels.Shadow = True
's.DataLabels.Font.Shadow = msoTrue
's.Points(pts.Count).DataLabel.Font.Shadow = msoTrue
's.Points(pts.Count).DataLabel(pts.Count).TextFrame.TextRange.Font.Shadow = msoTrue
End If
End If
Next s
End If
Next Shape
If someone will have problems with simillar case I have found the answer :)
The shadow (ribbon like shadow) for data label text/value is done via TextRange2 property, but I was missing Format. Like this :
Dim tr As TextRange2
Set tr = s.DataLabels(pts.Count).Format.TextFrame2.TextRange
With tr.Font.Shadow
.OffsetX = 10
.OffsetY = 10
.Size = 1
.Blur = 4
.Transparency = 0.5
.Visible = True
End With
Related
I want to give glow/shrink animation to a text in PowerPoint using VBA.
I can not configure it to give size 110% (it takes default size 150%) & also want a smooth end to 2 sec.
I tried the scale property but did not get my result.
Set osld = ActivePresentation.Slides(1)
Set dshp = osld.Shapes("LeftText")
osld.TimeLine.MainSequence.AddEffect dshp, msoAnimEffectGrowShrink, , msoAnimTriggerWithPrevious
For C = 1 To osld.TimeLine.MainSequence.Count
Set oeff = osld.TimeLine.MainSequence(C)
oeff.Timing.TriggerType = msoAnimTriggerWithPrevious
oeff.Timing.TriggerDelayTime = 2
'oeff.Behaviors.Add(msoAnimTypeScale).ScaleEffect.ByY = 110
'oeff.Behaviors.Add(msoAnimTypeScale).ScaleEffect.ByX = 110
Next C
Give this a try:
Sub GlowAnimationOptions()
Dim effGrowShrink As Effect
Set osld = ActivePresentation.Slides(1)
Set dshp = osld.Shapes("LeftText")
Set effGrowShrink = osld.TimeLine.MainSequence.AddEffect(Shape:=dshp, EffectID:=msoAnimEffectGrowShrink, Trigger:=msoAnimTriggerWithPrevious)
With effGrowShrink
With .EffectParameters
.Size = 120
End With
With .Timing
.SmoothEnd = msoTrue
.Duration = 4
End With
End With
End Sub
I want to change the same title of X-Y axis and format in many graphs at once using VBA.
I made code like below.
If I have 3 graphs, to change the second graph with the same X-Y axis titles and format, I copy and paste this code and change from ChartObjects(1) to ChartObjects(2), and also to change third graph, I also copy and paste this code again, and change as ChartObjects(3).
However, if I have 100 graphs, it seems impossible to copy and paste same codes 100 times, and change each ChartObjects.
Are there any methods to change X-Y axis titles in many graphs more easily?
Many thanks,
Sub axis()
Dim xytitle As chart
Set xytitle = Worksheets("graph").ChartObjects(1).chart
With xytitle.axes(xlCategory)
.HasTitle = True
.AxisTitle.Text = "Treatment"
.AxisTitle.Font.Size = 11
.AxisTitle.Font.Bold = False
End With
With xytitle.axes(xlValue)
.HasTitle = True
.AxisTitle.Text = "Grain weight"
.MaximumScale = 60
.MajorUnit = 10
.AxisTitle.Font.Size = 11
.AxisTitle.Font.Bold = False
End With
End Sub
I figured out the solution!! Thank you:)
Sub axis()
Dim xytitle As Chart
Dim i As Integer
For i = 1 To 4
Set xytitle = Worksheets("test").ChartObjects(i).Chart
With xytitle.Axes(xlCategory)
.HasTitle = True
.AxisTitle.Text = "Treatment"
.AxisTitle.Font.Size = 11
.AxisTitle.Font.Bold = False
End With
With xytitle.Axes(xlValue)
.HasTitle = True
.AxisTitle.Text = "Grain weight"
.MaximumScale = 60
.MajorUnit = 10
.AxisTitle.Font.Size = 11
.AxisTitle.Font.Bold = False
End With
Next
End Sub
I'm dealing with an issue where my VBA code somehow chooses not to include the whole chart when copying to a powerpoint slide. I have the following code:
This code creates my Doughnut chart from 2 numbers.
Function CreateTwoValuesPie(ByVal X As Long, ByVal Y As Long) As Chart
'Returnerer
Set CreateTwoValuesPie = charts.Add
CreateTwoValuesPie.ChartType = XlChartType.xlDoughnut
With CreateTwoValuesPie.SeriesCollection.NewSeries
.Values = Array(X, Y)
End With
With CreateTwoValuesPie
.ChartArea.Format.Fill.Visible = msoFalse
.ChartArea.Format.Line.Visible = msoFalse
.Legend.Delete
.ChartGroups(1).DoughnutHoleSize = 70
With .SeriesCollection(1)
.Points(1).Format.Fill.ForeColor.RGB = RGB(255, 158, 77) 'Score Orange
.Points(2).Format.Fill.ForeColor.RGB = RGB(175, 171, 170) '10 - Score GrĂ¥
.Format.Line.ForeColor.RGB = RGB(255, 255, 255)
End With
End With
End Function
This code store the different object and numbers:
Set oPPTApp = CreateObject("PowerPoint.Application")
Set oPPTFile = oPPTApp.Presentations.Open(PP)
Set oPPTShape10 = oPPTFile.Slides(1)
d11 = Format(Dashboard.EAScore1.Caption, "Standard")
Set ch1 = CreateTwoValuesPie(d11, 10 - d11)
ch1.CopyPicture Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
With oPPTShape10.Shapes.Paste
.Top = 127
.Width = 177
.Left = 393
End With
The code works fine and creates the correct chart from the number (d11, 10-d11) but when I copy the figure and insert it into my powerpoint slide oPPTShape10 it only copy part of the chart.
This can be seen in the image below:
The correct should've look like the one in the image below:
It worked some days ago and I haven't changed anything since then? Does anyone know how I can make it show the whole figure instead of only the topleft corner of it?
I am trying to change the text size in a textbox in Excel using VBA. I currently have the following code:
ActiveSheet.Shapes.Range(Array("textEnemy")).Visible = True
ActiveSheet.Shapes.Range(Array("textEnemy")).Select
With Selection.ShapeRange(1).TextFrame2.TextRange.Characters
.Text = msg
For i = 1 To 15
.Font.Size = i * 10
Call WasteTime(50)
Next
End With
ActiveSheet.Shapes.Range(Array("textEnemy")).Visible = False
This code animates the text increasing in size, and then it disappears. The problem is that when I run this code the textbox is selected (there is a box around it). How can I achieve the same goal without selecting the textbox/showing the selection border around it?
Thanks!
As #findwindow says:
With ActiveSheet.Shapes.Range(Array("textEnemy"))
.Visible = True
With .ShapeRange(1).TextFrame2.TextRange.Characters
.Text = msg
For i = 1 To 15
.Font.Size = i * 10
Call WasteTime(50)
Next
End With
.Visible = False
End With
I found a solution. I had to set the textbox as a shape variable, and then adjust it.
Sub Animate(playerCode As Integer)
Dim i As Integer
Dim msg As String
Dim textBox As Shape
msg = "HIT!"
Set textBox = ActiveSheet.Shapes("textUser")
'Animate textbox
textBox.Visible = True
With textBox.TextFrame2.TextRange.Characters
.Text = msg
For i = 1 To 15
.Font.Size = i * 10
Call WasteTime(50)
Next
End With
textBox.Visible = False
End Sub
I am using a small VBA program to apply some text in the background. I am able to apply watermark but if I use any image in the presentation then the watermark goes behind that image. Is there any way to keep the watermark always in front.
I am using this code to apply watermark :
Dim cntDesigns As Integer
cntDesigns = ActivePresentation.Designs.Count
For iter = 1 To cntDesigns
Dim curDesign As Design
Set curDesign = ActivePresentation.Designs.Item(iter)
' EnumerateMasters
Dim masterCount As Integer
masterCount = 1
Dim masters(100) As Master
Set masters(masterCount) = curDesign.SlideMaster
Dim cntLayouts As Integer
cntLayouts = curDesign.SlideMaster.CustomLayouts.Count
For Layout = 1 To cntLayouts
Dim curLayout As CustomLayout
Set curLayout = curDesign.SlideMaster.CustomLayouts(Layout)
If curLayout.DisplayMasterShapes = msoFalse Then
masterCount = masterCount + 1
Set masters(masterCount) = curLayout
End If
Next Layout
For masterIter = 1 To masterCount
Dim shape As shape
Set shape = masters(masterIter).Shapes.AddTextbox(msoTextOrientationHorizontal, 0#, 0#, 100#, 100#)
shape.TextEffect.Text = "Watermark"
shape.Height = 100
shape.Width = 100
shape.TextFrame2.WordWrap = msoTrue
shape.TextFrame2.WarpFormat = msoWarpFormat1
shape.Left = 100
shape.Top = 200
Next masterIter
Next iter
No, anything you put on top of something will cover it up. There's no "Keep this shape on top" command.
You can, however, trap one or more events that are likely to happen often (selection change, for example) and let that event trigger code that looks at each shape on the slide(s) and moves your watermark shape to front if it's not already there.