Change Color Palette via VBA

A

Ajmufic

Hi all.

Can anyone tell me how to change the RGB values for some colors in the Color
Palette, via VBA? Tried to record a macro while I changed some colors, but
the recorded macro came back blank...
 
C

Chris Roth [Visio MVP]

Hi Ajmufic,

Just messing around in the VBA immediate window, I found some properties
that might interest you:

?visio.ActiveDocument.Colors.Count
24
?visio.ActiveDocument.Colors(1).Red
255
?visio.ActiveDocument.Colors(1).Blue
255
?visio.ActiveDocument.Colors(1).Green
255

So you can see that you can get at the colors in a document and get/set
their RGB values.

You might also look at Visio Styles and Themes as a way of changing
colors "globally"


--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 
A

Ajmufic

Thanks Chris,

worked like a charm!
Now I'm gonna try to figure out the smartest way to distribute the script to
the users in our domain that have Visio installed (ca. 25%) and to make sure
that all new installations come with the correct (our) Color Palette.

I anyone have any suggestions I gladly accept them!

/Ajmufic
 
C

Chris Roth [Visio MVP]

Hi Ajmufic,

Which version of Visio are you using? I wonder if you could define your
standard colors using the new Themes feature instead of re-defining the
color pallette.

Or at least just extend Visio's colors to include your standard colors.

The problem with re-defining them is:

1. You have to go through all the drawings and update them.
2. If someone drags your shapes into a "standard" Visio drawing, the
"home-field colors" will win, so your company's shapes might turn out
really weird looking in the target documents.

My Visio-sense is thinking there might be other ways to solve this
problem that might cause fewer problems down the road...

--
Hope this helps,

Chris Roth
Visio MVP


Visio Guy: Smart Graphics for Visual People

Articles: http://www.visguy.com
Shapes: http://www.visguy.com/shapes
Dev: http://www.visguy.com/category/development/
Forum: http://www.viguy.com/vgforum
 
A

Ajmufic

Hi Chris,

we're talking about Visio 2003 here.
If I'm not mistaken, Themes is a new future in 2007, correct? We will
probably switch, but I don't know when. And as far as I could see it doesn't
seem to be enough colors to change in a Theme. We need 8 colors, beside White
and Black.

Unfortunately there had been a miss in the communication and I was NOT
suppose to chande the Color Palette...
What I needed to change were the colors under "Fill color". Do you know if
these even possible to modify?

/Ajmufic
 
A

Ajmufic

Does anyone know if it is possible to change the colors under "Fill color"?
How?
 
W

Wim

Does anyone know if it is possible to change the colors under "Fill color"?
How?

Hi,
I was looking for the same.
Solution:
Record a macro; change fill color, line color or whatever; stop
recording and look with the vba editor to the resulting code!

Here's the result for changing global line color:

Sub Macro1()
'
' test
'

Dim UndoScopeID1 As Long
UndoScopeID1 = Application.BeginUndoScope("Line Properties")
Application.ActiveDocument.GestureFormatSheet.CellsSRC
(visSectionObject, visRowLine, visLineColor).FormulaU = "RGB
(150,150,150)"
Application.EndUndoScope UndoScopeID1, True

End Sub
 

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

Similar Threads


Top