Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
HideoYamada
in reply to: martinhoos

Hello Martin,

 

Replace IColor() with the following :

Sub IColor()
    Dim doc As AssemblyDocument
    Dim designView As DesignViewRepresentation
    Dim viewFound As Boolean
    Dim repManager As RepresentationsManager
    
    Set doc = ThisApplication.ActiveDocument
    Set repManager = doc.ComponentDefinition.RepresentationsManager
    
    viewFound = False
    For Each designView In repManager.DesignViewRepresentations
        If designView.Name = "IColor" Then
            viewFound = True
            Exit For
        End If
    Next
    If Not viewFound Then
        Set designView = repManager.DesignViewRepresentations.Add("IColor")
    End If
    designView.Activate
    
    Dim occ As ComponentOccurrence
    Dim occ2 As ComponentOccurrence
    Dim index As Integer
    Dim index2 As Integer
    Dim localAsset As Asset
    Dim colorIndex As Integer
    
    colorIndex = 0
    
    For index = 1 To doc.ComponentDefinition.Occurrences.Count
        Set occ = doc.ComponentDefinition.Occurrences(index)
        If Left(occ.Appearance.DisplayName, 6) <> "IColor" Then
            Set localAsset = GetAsset(doc, colorIndex)
            For index2 = index To doc.ComponentDefinition.Occurrences.Count
                Set occ2 = doc.ComponentDefinition.Occurrences(index2)
                If occ.Definition Is occ2.Definition Then
                    occ2.Appearance = localAsset
                End If
            Next index2
            colorIndex = (colorIndex + 1) And 15
        End If
    Next index
End Sub

Does this work fine?

 

=====

Freeradical

 Hideo Yamada

=====
Freeradical
 Hideo Yamada
https://www.freeradical.jp