Rich text in a Visio shape

I need to place RTF text in a Visio shape from a .Net application. The Visio SDK documentation says that the Shape.PasteSpecial(visPasteRichText) method on a group shape should do the trick, but I get a COM exception: "Requested operation presently disabled."

I can't find an example anywhere in this forum on anywhere else on the internet. Can anyone post an example of putting rich text in a Visio shape?

Here's my code:

using System.Windows.Forms;
using Visio = Microsoft.Office.Interop.Visio;

public void Draw()
{
// Get some rich text.
RichTextBox rtfBox = new RichTextBox();
rtfBox.Text = "This is some rich text.";
rtfBox.SelectAll();
rtfBox.SelectionColor = System.Drawing.Color.Blue;

// Copy the rich text into the clipboard.
Clipboard.SetText(rtfBox.SelectedRtf, TextDataFormat.Rtf);

// Paste the rich text into a shape.
Visio.Shape visioShape = VisioInfo.Page.DrawRectangle(2, 2, 4, 4);
visioShape.ConvertToGroup(); // This avoids "Inappropriate target object for this action" exception.
visioShape.PasteSpecial((int) (Visio.VisPasteSpecialCodes.visPasteRichText), false, false); // This line throws "Requested operation presently disabled" COM exception.

}

The exception is thrown whether or not the new shape is selected.


Thanks for any help you can give me.

June 30th, 2010 4:33pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
June 30th, 2010 5:05pm

this might help in your understanding

http://blogs.msdn.com/b/visio/archive/2006/08/18/running-with-characters.aspx

al

 

  • Marked as answer by Sally Tang Thursday, July 01, 2010 7:50 AM
Free Windows Admin Tool Kit Click here and download it now
June 30th, 2010 5:05pm

Hi Larry,

You might be running into some locked behavior.

Check the ShapeSheet of your group and see if you've got this:

  Group Properties.SelectMode = 0

  Group Properties.IsTextEditTarget = 0 (or False)

Or

  Protection.LockTextEdit = 1 (or True)

The first one specifies that the user can't sub-select shapes within the group, and that the group isn't taking text. That means that Visio is trying to give the text to the top-most sub-shape inside of the group, but isn't allowed in because of the select mode. These cells correspond to settings in the Behavior dialog.

The second one is simply a lock against text editing.

 

July 1st, 2010 10:36am

Hi,

have you managed to solve this problem?

Thanks

Free Windows Admin Tool Kit Click here and download it now
June 17th, 2015 10:20am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics