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


    Sponsored Links


  • 1. Adding numbers to tiff images
    I've seen this done, but can someone point me in the right direction to learn how to do this myself? My ex boss, a vb programmer somehow used the clipboard to copy an .tiff image then add a footer (white line) with a number from a database field and saved it as a new tiff. It's called branding or endorsing tiff images and I'd like to write the codes myself in VBA or VB myself.
  • 2. UnicoWS.dll
    Does Visio 2003 use UnicoWS.dll? Thanks, marc
  • 3. Visio, IE and VBScript
    Hi, Does anyone know if it is possible (directly or using some workaround) to detect when a shape has been added to the page in Visio ActiveX control embedded in IE browser? So, when a shape has been added, do something.... How do I trap the shape added event in VBScript? Is it possible? Thanks, Claire
  • 4. Trouble with Copy/Paste
    Hello, I generate Visio drawings from an Access DB with the following process: 1-Generate a Temporary directory for each drawing 2-Copy Stencil file to the temporary directory of step 2 3-Open Stencil file with Visio, change masters caption with DB contents, save it and close 4-Generate a Visio drawing by automation from DB contents using drop operations from the stencil file. So, if I generate 2 drawings, they are based on 2 different stencil files (masters have the same BaseID, but different UniqueID). Let's take the following sample: - Drawing1 is composed of Shape1 based on the master named MASTER (from Stencil1) - Drawing2 is composed of Shape2 based on the master named MASTER (from Stencil2) MASTER has the 'Match master by name' property set to True. So, when I drag MASTER from Stencil1 To Drawing2, I get Shape3 that is based on MASTER. But If I copy Shape1 and paste it to Drawing2, I get Shape4 that is based on a new master (added to the Drawing2 document stencil) called MASTER.2 Is there a way to avoid this new master creation ? Or in the SelectionAdded event, a way to change the Shape4 master and then destroy MASTER.2 ? Thanks in advance, David.
  • 5. Programmatically going into connection mode
    Hi Is it possible to programmatically go into connection mode and if so how? Thanks for any help anyone can give. Marek

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 10 guest