Add new master to stencil with VB .NET

L

Lennard N.

Hi folks,

I have created a Ribbon-Add-In for Microsoft Visio with Visual Studio 2010 and I really like doing this so far, but I have one major problem that I can't get over.

I try to dynamically change the stencil by reacting to events like ShapeAdded. I managed to delete a master from the stencil by doing something like this:

vsoMaster.Delete()

However, if I want to add a new master to an empty stencil (after all masters have been deleted) I do this:

Dim vMaster = vsApplication.Documents.Item("test.vss").Masters.Add()

This produces an empty master in the stencil.
Now, if I want this master to have a shape, I always get COMExceptions, e.g. when I try to do stuff like this:

vMaster.Shapes.Item(1).CellsSRC(Visio.VisSectionIndices.visSectionObject, Visio.VisRowIndices.visRowLine, Visio.VisCellIndices.visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,0))"

It seems plausible for the program to react like that because there is no shape yet, but I can't find a way to assign a shape to the master.

Does anyone know a way to do that?

Thanks in advance for your help and best regards from Osnabrueck, Germany.

Lennard
 
P

Paul Herber

Hi folks,

I have created a Ribbon-Add-In for Microsoft Visio with Visual Studio 2010 and I really like doing this so far, but I have one major problem that I can't get over.

I try to dynamically change the stencil by reacting to events like ShapeAdded. I managed to delete a master from the stencil by doing something like this:

vsoMaster.Delete()

However, if I want to add a new master to an empty stencil (after all masters have been deleted) I do this:

Dim vMaster = vsApplication.Documents.Item("test.vss").Masters.Add()

This produces an empty master in the stencil.
Now, if I want this master to have a shape, I always get COMExceptions, e.g. when I try to do stuff like this:

vMaster.Shapes.Item(1).CellsSRC(Visio.VisSectionIndices.visSectionObject, Visio.VisRowIndices.visRowLine, Visio.VisCellIndices.visLineColor).FormulaU = "THEMEGUARD(RGB(0,0,0))"

It seems plausible for the program to react like that because there is no shape yet, but I can't find a way to assign a shape to the master.

Does anyone know a way to do that?

Thanks in advance for your help and best regards from Osnabrueck, Germany.

These newsgroups are no longer in use and it is unlikely that you will get an answer here.
There are replacement forums for Visio, Microsoft's own:
http://social.technet.microsoft.com/Forums/en-US/visiogeneral/threads
http://answers.microsoft.com/en-us/office/forum/visio?page=1&tab=all

or Visio MVP VisioGuy
http://www.visguy.com/vgforum/
 

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