Code:
Public Sub Passflächen()
Dim strColorName As String
strColorName = "RAL 1012 Zitronengelb"
On Error Resume Next
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.ActiveDocument
If Err Then
MsgBox "A part document must be active."
Exit Sub
End If
Dim oRenderStyle As RenderStyle
Set oRenderStyle = oPartDoc.RenderStyles.Item(strColorName)
If Err Then
MsgBox "The specified render style """ & strColorName & """ does not exist."
Exit Sub
End If
On Error GoTo 0
' Create a list of the selected faces.
Dim oFaceCollection As FaceCollection
Set oFaceCollection = ThisApplication.TransientObjects.CreateFaceCollection
Dim i As Integer
For i = 1 To oPartDoc.SelectSet.Count
On Error Resume Next
Dim oFace As Face
Set oFace = oPartDoc.SelectSet.Item(i)
If Err.Number = 0 Then
oFaceCollection.Add oFace
End If
Next
' Set the color of the selected faces.
For Each oFace In oFaceCollection
Call oFace.SetRenderStyle(kOverrideRenderStyle, oRenderStyle)
Next
End Sub