aruba1
Goto Top

Füllfarbe eines Vorhandenen Shapes ermitteln

Hallo,

ich habe folgendes Problem. Ich habe in einer Exceldatei verschiedene Shapes mit unterschidlichen Füllfarben. Wie kann ich per VBA den Wert der Füllfarbe eines Shapes ermitteln?

Mit den Texteigenschaften und den Größen und Positionsangaben hat schon geklappt.

Dim ClipAblage As DataObject
Set ClipAblage = New DataObject
X = 2
For Each m_shape In ActiveWorkbook.ActiveSheet.Shapes

If Left(m_shape.Name, 3) = "Ova" Then
Worksheets("CB").Range("BA" + CStr(X)).Value = m_shape.Name
Worksheets("CB").Range("BB" + CStr(X)).Value = m_shape.Top
Worksheets("CB").Range("BC" + CStr(X)).Value = m_shape.Left
Worksheets("CB").Range("BD" + CStr(X)).Value = m_shape.Height
Worksheets("CB").Range("BE" + CStr(X)).Value = m_shape.Width
m_shape.Select
With Selection
Rem Textinhalt
ClipAblage.SetText Selection.Characters.Text
If Selection.Characters.Text <> "" Then
Worksheets("CB").Range("BF" + CStr(X)).Value = Selection.Characters.Text
End If
Rem Schriftgrösse
ClipAblage.SetText Selection.Font.Size
Worksheets("CB").Range("BG" + CStr(X)).Value = Selection.Font.Size
Rem Schriftart
ClipAblage.SetText Selection.Font.Name
Worksheets("CB").Range("BH" + CStr(X)).Value = Selection.Font.Name
Rem Füllfarbe

End With
X = X + 1
End If

Vielen Dank für eure Hilfe im Voraus.

Content-Key: 156968

Url: https://administrator.de/contentid/156968

Printed on: April 25, 2024 at 15:04 o'clock

Mitglied: 76109
76109 Dec 14, 2010 at 18:20:41 (UTC)
Goto Top
Hallo aruba1!

In etwa so:
'....  
    For Each Shape In ActiveWorkbook.ActiveSheet.Shapes
        With Shape.OLEFormat.Object
            With .Font
                f_Name = .Name                  'String  
                f_Size = .Size                  'Double  
                f_FontStyle = .FontStyle        'String  
                f_Color = .Color                'Double  
                f_ColorIndex = .ColorIndex      'Long  
                f_Bold = .Bold                  'True(-1)/False(0)  
                f_Italic = .Italic              'True(-1)/False(0)  
            End With
            
            With .Interior
                i_Color = .Color                'Double  
                i_ColorIndex = .ColorIndex      'Double  
            End With
        End With
    Next
'....  
und anstelle von
With Shape.OLEFormat.Object
geht's auch mit
With Shape.DrawingObject

Gruß Dieter
Member: aruba1
aruba1 Dec 15, 2010 at 20:57:59 (UTC)
Goto Top
Hallo Dieter,

irgendwie klappt das nicht. Als Ergebnis kommt eine Farbe als Zahl raus, z. B. 16777215.

Hast du vielleicht noch eine Idee?

Vielen Dank
Mitglied: 76109
76109 Dec 16, 2010 at 16:17:52 (UTC)
Goto Top
Hallo aruba1!

Zitat von @aruba1:
irgendwie klappt das nicht. Als Ergebnis kommt eine Farbe als Zahl raus, z. B. 16777215.
Was heißt klappt nicht?

Dezimal 16777215 = der Farbwert für Weiß (Hex FFFFFF) und als ColorIndex hast Du den Wert --4105 und der steht für die Konstante XlAutomatic bzw "Keine Füllung"

Gruß Dieter