Removing Data Graphics via VB

Started by biohaz201, July 02, 2008, 08:35:18 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

biohaz201

Hi,

I am fairly new to Visio but I was wondering if there was a to remove data graphics from a shape?  As it stands now I am in the middle of creating an document that automatically pulls in data and draws a physical representation of every server rack.  Works great so far, except I am only able to apply data graphics, not being able to remove them hinders my ability to add some functionality.

Code for applying the graphic

ActiveWindow.SelectAll
Set vsoSelection = ActiveWindow.Selection
vsoSelection.DataGraphic = ActiveDocument.Masters("Data Graphic")
ActiveWindow.DeselectAll

Manually a person can remove the data graphic, so I see no reason to not be able to do it with VB.  Using "None" in place of "Data Graphic" returns an error.  "Data Graphic" is a custom one I made.

Any help is appreciated.

Visio Guy

Hi biohaz,

These two lines work for me:


' Apply a Data Graphic:
Visio.ActiveWindow.Selection.DataGraphic = Visio.ActiveDocument.Masters("Data Graphic 2")

' Apply no data graphic:
Visio.ActiveWindow.Selection.DataGraphic = Nothing


Note: the keyword "Set" is not used, and won't work if you do. I'm not sure why. And in VB and VBA, you'll want to use "Nothing" not "None". There is no master named None that holds an empty data graphic, despite what is shown in the Data Graphics panel.

For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010

biohaz201

I appreciate you lending me a hand.  What you suggested worked quite fine.  Sorry for the late post just got caught up with the holiday weekend.


Visio Guy

July 4th is the hardest day of the year for me, living here in Europe.

Hope all you Yankees (and Dodgers) enjoyed the fireworks!
For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010