I hope you all are well. I am stuck in coding or you can say formatting problem and I have tried everything and somehow I am not able to workout how it would be done. The description of the problem below.
Problem : We wanted a vba macro for PowerPoint by using we can set the below (check screenshot) formatting for a selected cell in a PowerPoint selected table. I have manage to write the code to add that, but we wanted a horizontal line with 45 degree of angle, I managed to add two color gardient, but I am not able to add the horizontal line with 45 degree, it comes from top to down or way to sharp.
May I request any pointer please, I am not sure what I am doing wrong.
Code
Sub Fill()
Dim oSh As Shape
Dim iStyle As Integer
Dim iVariant As Integer
Dim iAngle As Integer
Dim Col1 As Long
Dim Col2 As Long
Dim Col3 As Long
Col1 = RGB(255, 0, 0) 'red
Col2 = RGB(255, 192, 0) 'green
Col3 = RGB(255, 255, 0) 'yellow
Dim oTbl As Table
Dim lRow As Long ' your i
Dim lCol As Long ' your j
Set oSh = ActiveWindow.Selection.ShapeRange(1)
Set oTbl = oSh.Table
With oTbl
For lRow = 1 To .Rows.Count
For lCol = 1 To .Columns.Count
If .cell(lRow, lCol).Selected Then
With .cell(lRow, lCol).Shape.Fill
.TwoColorGradient msoGradientHorizontal, 1
.GradientStops(1).Color = Col1
.GradientStops(1).Position = 0.5
.GradientStops(2).Color = Col2
.GradientStops(2).Position = 0.5
.GradientAngle = 60
End With
End If
Next
Next
End With
End Sub
Desired Output


If you really want 45 degree slopes regardless of the height of the cell, you can get pretty close using something like the calculation below
Here's my test slide, with 45 degree lines positioned over the shapes "Box0" to "Box6":
Note I only worked this out for the case where
h > w