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


    Sponsored Links


  • 1. Moving pages takes awfully long
    Hi, i have a 1200 page document here and want to sort the pages, but it takes awfully long (about 7 minutes) for the macro to move one page. I already tried to set ShowChanges to false but that didn't improve the situation much. I'm wondering what Visio does while moving pages. I'm running Visio 2003 on a P4 2,4 with 1GB RAM Regards Aydan
  • 2. Bug in Shape.DistanceFrom ??
    I tried to use the DistanceFrom property of the Shape object in Visio to compute the distances between two shapes. However, I found that for two shapes A and B, the values for A.DistanceFrom(B, 0) and B.DistanceFrom(A, 0) are sometimes different. I opened a new Flowchart (Metric) drawing, placed two "Process"es next to each other horizontally. resized one so that they are of different sizes, and making sure that the top and bottom sides of the two rectangles are not on a straight line. Then I tried the code: Debug.Print ActiveWindow.Page.Shapes.ItemFromID(1).DistanceFrom(ActiveWindow.Page.Shapes.ItemFromID(2), 0) Debug.Print ActiveWindow.Page.Shapes.ItemFromID(2).DistanceFrom(ActiveWindow.Page.Shapes.ItemFromID(1), 0) and found that they output different values. Is this normal?
  • 3. Detect drag from another document
    Hi there, Can anyone tell me how I should go about swapping a shape dragged in from a source document to a shape based on a master in the target document? I was thinking of using the ShapeAdded event so that I can get the PinX/Y of where the shape was dropped, delete it and then add a new shape in the same place. What I'm having trouble with is how to detect whether a shape was dragged in from another document or if it came from, say, another page within the same document? Any clues? Thanks John
  • 4. How to find PinX and PinY of group shape relevant to Page
    Hi PinX and PinY cells are giving correct coordinate relevant to current page and based of that, I am creating my other display field shapes just below the orignal shape. Now after adding in group, PinX and PinY giving coordinate based on their parent shape and not the parent page. How can I get X and Y coordinate of a shape relevant to Page. Thanks Shahzad Godil
  • 5. ufsdump/restore size limit?
    I'm having a problem restoring a fairly large file system under Solaris 8. The hardware is a Sun Fire V240, with a third-party SCSI-to-SCSI raid controller. The filesystem is just shy of 300 GB, with about 100 GB in use. We're using ufs, and ufsdump and ufsrestore, dumping to an SDLT drive that's directly attached to the V240. We are current with Solaris 8 patches. We periodically restore the dumps to an old machine that we use for testing, just to make sure that they can be restored. I can no longer restore the dumps -- ufsrestore asks for a second tape, when there isn't one. Even if we dump to a file on another server, and then try to restore from that, ufsdump still asks for a second tape/file to restore from. The dump files don't appear to be truncated. Are there any limits to what ufsdump & restore can handle? I sure can't find anything about this.

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