Visio 2010 Programmatically change Shape fill color using C#

Discussion in 'Visio' started by Ilan Bar, Aug 13, 2015.

  1. Ilan Bar

    Ilan Bar

    Joined:
    Jul 8, 2015
    Messages:
    2
    Likes Received:
    0
    From my C# code, I am trying alter a shape's background to highlight it in response to a given criteria. I researched all visio forums and came up with the following methods:

    first method:

    shape.CellsSRC[(short)VisSectionIndices.visSectionObject,(short)VisRowIndices.visRowFill,(short)VisCellIndices.visFillForegnd].FormulaU="RGB(255,0,0)";
    second method:

    ArrayList sourceStream =newArrayList();ArrayList formula =newArrayList();

    sourceStream.Add((short)VisSectionIndices.visSectionObject);
    sourceStream.Add((short)VisRowIndices.visRowFill);
    sourceStream.Add((short)VisCellIndices.visFillForegnd);

    formula.Add("RGB(255,0,0)");

    Array arrSourceStream = sourceStream.ToArray(typeof(short));Array arrFormula = formula.ToArray();

    shape.SetFormulas(ref arrSourceStream,ref arrFormula,(short)VisGetSetArgs.visSetUniversalSyntax);

    None of the methods resulted in change in the shape's color. Additional information:
    1) trying to change shape's line color or pattern by changing the VisCellIndices enum gives the same result - no change
    2) I am able to add custom cell properties to the shape
    3) I am able to alter shape's text using the "Text" property

    I am completely stuck!! any ideas?
    Regards, Ilan
     
    Ilan Bar, Aug 13, 2015
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.