Shape color change problem (with code sample) 
Author Message
 Shape color change problem (with code sample)

Can someone tell me why the UML Component shape color change code below does not work? I'm using Visio for Enterprise Architects (2002). Thanks in advance for any help!

Public Sub TestColorChange()
    Dim oUMLComponentStencil As Document
    Dim oComponentMaster As Master
    Dim oDroppedShaped As Shape
    Const sUML_COMPONENT_STENCIL = "UML Component (US units).vss"

    On Error Resume Next  ' temporary
    Set oUMLComponentStencil = Documents(sUML_COMPONENT_STENCIL)  ' get a reference to the Stencil object
    If oUMLComponentStencil Is Nothing Then  ' the stencil was not open, we need to open it
        On Error GoTo ErrorHandler  ' back to normal error handling
        Set oUMLComponentStencil = Documents.OpenEx(sUML_COMPONENT_STENCIL, visOpenRO)
    Else
        On Error GoTo ErrorHandler  ' back to normal error handling
    End If
    Set oComponentMaster = oUMLComponentStencil.Masters("Component")  ' get a reference to the component shape
    Set oDroppedShaped = ActivePage.Drop(oComponentMaster, 1, 1)
    oDroppedShaped.Cells("FillForegnd").Formula = "RGB(0,204,255)"  ' change the color to sky blue

    Exit Sub

ErrorHandler:
    Err.Raise Err.Number
End Sub

--
Please remove all UPPERCASE letters in the reply email address!



Wed, 27 Apr 2005 05:36:54 GMT  
 Shape color change problem (with code sample)
Many of the UML shapes are grouped, so you will need to apply color to each
sub shape:
dim oShape as Visio.Shape
if (oDroppedShape.Shapes.Count > 0) then
    for each oShape in oDroppedShape.Shapes
        oShape..Cells("FillForegnd").Formula = "RGB(0,204,255)"
    next oShape
endif

Hope this helps,

Bill

This posting is provided "AS IS" with no warranties, and confers no rights.



Can someone tell me why the UML Component shape color change code below does
not work? I'm using Visio for Enterprise Architects (2002). Thanks in
advance for any help!

Public Sub TestColorChange()
    Dim oUMLComponentStencil As Document
    Dim oComponentMaster As Master
    Dim oDroppedShaped As Shape
    Const sUML_COMPONENT_STENCIL = "UML Component (US units).vss"

    On Error Resume Next  ' temporary
    Set oUMLComponentStencil = Documents(sUML_COMPONENT_STENCIL)  ' get a
reference to the Stencil object
    If oUMLComponentStencil Is Nothing Then  ' the stencil was not open, we
need to open it
        On Error GoTo ErrorHandler  ' back to normal error handling
        Set oUMLComponentStencil = Documents.OpenEx(sUML_COMPONENT_STENCIL,
visOpenRO)
    Else
        On Error GoTo ErrorHandler  ' back to normal error handling
    End If
    Set oComponentMaster = oUMLComponentStencil.Masters("Component")  ' get
a reference to the component shape
    Set oDroppedShaped = ActivePage.Drop(oComponentMaster, 1, 1)
    oDroppedShaped.Cells("FillForegnd").Formula = "RGB(0,204,255)"  ' change
the color to sky blue

    Exit Sub

ErrorHandler:
    Err.Raise Err.Number
End Sub

--
Please remove all UPPERCASE letters in the reply email address!



Thu, 28 Apr 2005 05:04:57 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. sample code: find all connected shapes

2. Shaping Forms. Code Sample Here

3. dynamically change shapes and colors with VBA

4. Changing a shapes color from VBA

5. Change colors in entity shapes

6. How to change fill color in a shape?

7. Change Colors of Shapes in VBA

8. (Changing the background color of a shape) Another Newbie Question

9. Change grouped shape color through VBA?

10. Change Shape's Line Color through VBA

11. shape doesn't change color????

12. PROBLEM: Colors change at different color depths

 

 
Powered by phpBB® Forum Software