Add shapes and change their color at the same time through VBA


    Sponsored Links


  • 1. High level questions on ēŽ eveloping with Vision 2003
    Hi there, It doesn't have a SDK development documentation on MSDN yet for Visio 2003, Does 2002 would be pretty similar or can we find a SDK development documentation for 2003 somewhere else. I will need to develop an application using Visio (hopefully 2003). - Automate values in objects (drawing); - Validate validity of links between objects ; - Export information in a specific xml format . Am I on the good way to do it by looking for an SDK documentation (2003) or I should look for other tools also ? If so, what are those tools and where should I find them with the documentation ? Thanks to anybody that can help me
  • 2. icon on toolbar
    Hi I am trying to put an icon on the toolbar during installation that will launch my program. It works for the admin (I installed as admin), but if I switch to a user account, the icon is missing. How do I do it so all users can run the program It needs to work for Visio 2003 and 2002. I would appreciate the help. I need to deliver this to a customer. Thank Chris
  • 3. How to ungroup shape through Automation without getting a Message
    I am developing a graphical editor based on the Visio Active X control. For one of the editors' features, I need to drop a Master on a document and ungroup it through automation. The problem is that no matter what method I am using to ungroup the shape, the user sees the message: his action will sever the object link to its master I tested the Shape.Ungroup() and Window.DoCmd(VisUICmds.visCmdObjectUngroup) methods. My attempts to get the QC_Ungroup event failed from automation. I was able only to get the event when I ungrouped shape from the UI. Does anybody have any suggestions on how I can get rid of this dialog?
  • 4. COM Add-in unloads when an Add-on is run throgu the custom menu
    Hi Everyone, I have created a COM Addin to get some smart functionlaity on the drawing objects. It works fine, and I have created another add-on to run through the menu. As soon as I run this add-on through the Menu, the COM Add-in unloads. If this is normal how do I run a menu Item and run a public method on the same COM Add-in. Tx in Advance Gamini Jayarathne

Add shapes and change their color at the same time through VBA

Postby consulttech2004 » Sat, 19 Jan 2008 05:24:09 GMT

I want to use the ShapeAdded event so that when I add a shape from an
electrical stencil, the shape turns red (or green, or blue, or
whatever) so that it stands out from the rest of my drawing.  Any
ideas on how to do this consistantly through VBA?  Thanks in advance.

(VISIO Newbie)

Re: Add shapes and change their color at the same time through VBA

Postby John Goldsmith » Sat, 19 Jan 2008 06:31:01 GMT

Hello David,

For events, checkout this link:

 http://www.**--****.com/ (office.10).aspx (DVS - 
Handling Visio Events)

For the change of fill colour, you can use the macro recorder (Tools / Macro 
/ Record new macro...) to record the code as you make the changes manually 
in the UI, which you can then integrate into you final solution.

Are you sure, by the way, that you can't achieve what you're after just 
using the ShapeSheet?  On what basis do you want the colour to change?

Best regards


John Goldsmith

Similar Threads:

1.Changing color of shape with VBA code...

I would like to change the color of a shape with VBA code.  How can this be 
done?  code examples?

In the long run i would like to be able to do this using data from a 
database, controlled by the VBA code.  Thanks!

2.Change color of shape

I'm aware about reports that the Visio 2003 .NET/C# SDK will be
released somewhere Q1-2004. However I'm hoping that somebody can give
me a hint beforehand how to achieve to change the color of a shape

I got it working to find the selected Visio shape. And I can change
the text, however I don't have the slightest idea how to change the
color of the shape.

Maybe through SetFormula() but I don't understand what the arguments

//this works:
this.selectedShape.Text = visio_term + " exists";

//but what is SRCStream and formulaArray?
this.selectedShape.SetFormulas(ref SRCStream, ref formulaArray, 0);

The documentation does not reveal more then

public abstract new System.Int16 SetFormulas ( System.Array
SRCStream , System.Array formulaArray , System.Int16 Flags )
Member of Microsoft.Office.Interop.Visio.IVShape

Any one has a clue?


3.Change fill color of shape through code

I have been making my own master shapes.  I note that I can change the
fill color of some master shapes through code using the following

Shape.FillStyle = "red"

Or whatever I have defined my style to be.  It works pretty well for
our purposes.  The problem is that some master shapes don't seem to
have a fill color, and some that I have drawn (all of them, in fact)
don't seem to want to change color through VBA no matter what I do.
Is there something I'm missing?  Thanks in advance,


4.Change shape background color on a visio stencil


does somebody know how to change the background color of a shape already 
inserted to a stencil?

The problem is that I have to use a transparent image. When I drop it to the 
stencil, the background is transparent and the image quality is really bad 
(unrecognizable). If the background color of the image is white, the icon has 
a good quality and is recognizable.

Thanks, udo

5.How to Change Color of a Group of Shapes

Hi, Gurus,

I have a Visio program.   I created a group of line shapes.  I want to 
change the colors of all lines when a specific data goes beyond the range, 
say, if value > 1000.  How can I do that by using the group properties with 

Thanks so much in advance.


6. How to change Visio Shape color with vb???

7. Excel VBA - Add Sheet Change Event at Run Time

8. change font color of tasks or color of bars from VBA

Return to VISIO


Who is online

Users browsing this forum: No registered users and 88 guest