How do you change a shapes background color?

J

Joseph Burton

I was able to figure out how to reference the shape on the page, but I would
like
to change the color of the shapes background.

In visio you would right click on the shape,
Go to format
click on the fill method
and then chose the color.

I'm trying to do this from code, but can't figure it out.

appVisio = CType(CreateObject("Visio.application"), Visio.Application)
docsObj = appVisio.Documents
docsObj.Open("C:\Documents and Settings\joe\Desktop\JoeDrawing.vsd")

pagsObj = appVisio.ActiveDocument.Pages

pagObj = pagsObj.Item(1)

'point to shape
shpObj = pagObj.Shapes.Item("EmployeeName")

appVisio.Quit()
 
J

John Marshall, MVP

Shapes can be simple or groups so the method of fill may change. For a
simple shape:

shpObj.Cells("FillPattern") = 35 ' Set fill pattern to one of available
graduated fill patterns.
shpObj.Cells("FillForegnd") = 2 ' Set fill foreground color to red.
shpObj.Cells("FillBkgnd") = 3 ' Set fill background color to green.

For a group shape you will have to loop throught the componenet shapes.

In 2003, use the macro recorder to get an idea of what needs to be done with
a specific shape.

John... Visio MVP

Need stencils or ideas? http://www.mvps.org/visio/3rdparty.htm
Need VBA examples? http://www.mvps.org/visio/VBA.htm
Common Visio Questions http://www.mvps.org/visio/common_questions.htm
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Top