YorickG
10-16-2017, 03:46 AM
Hello all, probably a very newbie question, however I can't figure it out.
I want to check RGB values of text in shape. Shapes have random names (for example Title, Title 2, Title 3). My code works in case there is shape "Title" and "Title 2" present on slide. How to modify this code to work with only one shape present. ID titles are random. So it should work with name for example from range Title - Title 10.
Dim N As Long, R As Long, G As Long, B As Long Dim shp As Shape
Dim titleShp() As Variant
On Error Resume Next
For i = 1 To N
Next i
If ActiveWindow.View.Slide.Shapes("A1a").Visible = False Then
MsgBox "There is no color palette on this slide :)"
End If
titleShp = Array("Title", "Title 2")
'ACCENT1 - CODE
With ActiveWindow.View.Slide.Shapes("A1a")
.Fill.ForeColor.RGB = ActiveWindow.View.Slide.Shapes.Range(titleShp).TextFrame.TextRange.Font.Col or
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
.TextFrame.TextRange.Font.Size = 7
.TextFrame.TextRange.Font.Bold = True
N = ActiveWindow.View.Slide.Shapes.Range(titleShp).TextFrame.TextRange.Font.Col or
B = N \ 65536
G = (N - B * 65536) \ 256
R = N - B * 65536 - G * 256
.TextFrame.TextRange.Characters.Text = "Title: " & "R:" & R & " G:" & G & " B:" & B
End With
I want to check RGB values of text in shape. Shapes have random names (for example Title, Title 2, Title 3). My code works in case there is shape "Title" and "Title 2" present on slide. How to modify this code to work with only one shape present. ID titles are random. So it should work with name for example from range Title - Title 10.
Dim N As Long, R As Long, G As Long, B As Long Dim shp As Shape
Dim titleShp() As Variant
On Error Resume Next
For i = 1 To N
Next i
If ActiveWindow.View.Slide.Shapes("A1a").Visible = False Then
MsgBox "There is no color palette on this slide :)"
End If
titleShp = Array("Title", "Title 2")
'ACCENT1 - CODE
With ActiveWindow.View.Slide.Shapes("A1a")
.Fill.ForeColor.RGB = ActiveWindow.View.Slide.Shapes.Range(titleShp).TextFrame.TextRange.Font.Col or
.TextFrame.TextRange.Font.Color.RGB = RGB(255, 255, 255)
.TextFrame.TextRange.Font.Size = 7
.TextFrame.TextRange.Font.Bold = True
N = ActiveWindow.View.Slide.Shapes.Range(titleShp).TextFrame.TextRange.Font.Col or
B = N \ 65536
G = (N - B * 65536) \ 256
R = N - B * 65536 - G * 256
.TextFrame.TextRange.Characters.Text = "Title: " & "R:" & R & " G:" & G & " B:" & B
End With