Hi!
I import some data from Word document and paste it into a worksheet.
The word document contain both text and many small images. The images are only with 4 colors, but many of them.
I want to get the color of images.
I get the RGB color number, but they all have the same number. It should be 4 different color number.
I wonder how I can dethatch a small Excel Worksheet in this Forum, so you can se the images.
https://1drv.ms/f/s!AuZtyv5z6GO9aA-J72juKjF4MBg
I import some data from Word document and paste it into a worksheet.
The word document contain both text and many small images. The images are only with 4 colors, but many of them.
I want to get the color of images.
I get the RGB color number, but they all have the same number. It should be 4 different color number.
I wonder how I can dethatch a small Excel Worksheet in this Forum, so you can se the images.
HTML:
Function ShapeAtActiveCell() As String
'
Dim Sh As Shape
For Each Sh In ActiveSheet.Shapes
If Sh.TopLeftCell.Address = ActiveCell.Address Then
ShapeAtActiveCell = Sh.Name
ActiveSheet.Shapes(ShapeAtActiveCell).Select
Exit Function
End If
Next
End Function
'-------------------------------------
Sub GetColor()
Dim shp As Shape
Dim R As Integer, G As Integer, B As Integer
Dim colr As Double
Dim j As Long
j = 2
Worksheets("Sheet1").Activate
Range("B2").Select
For i = 1 To 4
ActiveSheet.Shapes(ShapeAtActiveCell).Select
Set shp = ActiveSheet.Shapes(Selection.Name)
colr = shp.Fill.BackColor.RGB
R = colr Mod 256
G = (colr \ 256) Mod 256
B = (colr \ 256 \ 256) Mod 256
Cells(j, "C").Value = colr
Cells(j, "D").Value = R
Cells(j, "E").Value = G
Cells(j, "F").Value = B
ActiveCell.Offset(1, 0).Select
j = j + 1
Next i
End Sub
Last edited by a moderator: