none
PasteSpecial:- Command failed in VSTO word 2007 RRS feed

  • Question

  • Hi All,

    This is one serious problem I facing for last few days.

    When I am trying to pasteSpecial in content control, sometimes I receive this error:-Command failed.

    Again if I close and reopen the word and try it, it works fine.

    Is there any solution for the same. Client is very upset with this.

    Any help is appreciated.

    Thanks,

    Dipankar

    Saturday, February 18, 2012 8:09 AM

All replies

  • Please show us the code that deals with Paste Special. Including the parts that determine where the paste speical target is.

    Cindy Meister, VSTO/Word MVP

    Sunday, February 19, 2012 8:26 AM
    Moderator
  • Here is the code sample:-

      object typeHtml = (object)Word.WdPasteDataType.wdPasteHTML;
                                contentControls.get_Item(ref i).Type = Microsoft.Office.Interop.Word.WdContentControlType.wdContentControlRichText;
    contentControls.get_Item(ref i).Range.Text = "";
                               
                               HtmlFragment.CopyToClipboard(contentControlData);             
                                contentControls.get_Item(ref i).Range.Select();
                        
                                Globals.ThisAddIn.Application.ActiveDocument.Application.Selection.PasteSpecial(ref missingVal, ref missingVal,ref missingVal, ref missingVal, ref typeHtml, ref missingVal, ref missingVal);

    This line is giving error...

    Tuesday, February 21, 2012 4:18 AM