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


    Sponsored Links


  • 1. Associate text with certain positions on org chart
    Using Visio 2002 SP2. Is there a way to attach or associate text to a shape; perhaps something like a cell note in MS-Excel? Or is there a built-in note pad one could open where some textual notes could be added about a shape? The reason is, we are looking at developing an org chart, but for some positions we would like to add some notes about the positions; e.g. for justifications, approvals, under filled positions, promotions, demotions, lateral moves, etc. These notes could be rather long, and I'm presuming, not appropriate for a custom property of the shape? How long can a custom property be? We could need up to say about the equivalent of one page in a MS-Word document at Arial 10-point font with half-inch margins. If this is built-in, how do I access it? If not built-in, any suggestions on creating something using VBA? Should I consider hyperlinking to separate MS-Word documents? Ideas? Thanks much in advance.
  • 2. Connect two shapes together
    Hi, I would like to know if it is possible to create a VBA macro for visio which allows a user to select two shapes and click a button which executes a macro that connects the two shapes together. Is it possible to pass information about the selected shapes to the macro? How would I do this? Thanks
  • 3. General Visio question
    I and my org are new to VISIO; my forte is VBA programming primarily in MS-Excel, but I also use MS-Access a lot and I also am coming up to speed rapidly using VBScript. Question: Is it possible to program VISIO in combination with Excel and/or Access so that given VISIO org charts (for each department/division), users could make edits and when done, their changes could be captured and written into a spreadsheet or DB table using VBA (i.e. automated data capture)? The type of information to capture would be: Employee Name; Department; Subdivision; Answers To (based on structure of org chart); Pay Grade; Title; Employee Status (i.e. Full/Part time; temp; etc.). I picture this info in a box for each employee on a separte org chart for each Dept. and/or Subdivision. Is this a realistic goal? Or would this be a very difficult/impossible task? The main problem I see is parsing the information as it is captured from each box; e.g. where does the Division name end and the Job Title begin, etc? Thanks much for your input.
  • 4. Guru Question Visio 2007 Auto Generate Shapes according to data so
    Hi, I was hoping someone might be able to tell me how I get visio to automatically insert a shape according to an excel spreadsheet or sql database. IE: I have 400 servers I want to put on a visio drawing. All these servers have a unique server name that I would like the shape to have as it's text name. Is it possible to create some kind of automatic generation of shapes according to the number of records contained in a data source and spit them out on a page. EG: Data Source Server1 Server2 Server3 Then 3 server shapes are automatically placed on a visio document called server1, server2, server3 I hope someone can help! Thanks
  • 5. Help on Org Chart (Visio 2002)
    Hello I have pulled a sample code from the newsgroups on creating the org chart wizard from an excel data source. But need additional help. Using VBA: 1) is it possible to programmatically change the org chart shapes? 2) how do i create the dotted connector from the CEO to Admin Assistant? 3) how to change the layout to side-by-side? 4) on my sample dataset, I need to create an org chart by country and product. The user will be given the choice to create the org chart by how many product they selected (up to five, via a listbox) How can I organize the org chart - say the user selected all 5 products,I will have one page for each country and under each country, the product1 to product5 will show up from left to right? In USA, Product1 = there will be 10 people Product2 = there will be 40 people Product3 = there will be 50 people Product4 = there will be 20 people Product5 = there will be 35 people (of course over time, this will change due to new hires and turnaround of employees) 5) when changing the round corners from the Format - Line option, this seems to only work for the connectors but the bot the shape themselves. Is this possible to adjust? I would appreciate any help. Many thanks! Bob

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