none
C# - How to use AddPolyline Method RRS feed

  • Question

  • Hello,

     

    can anyone tell me what the type of argument to pass for the first argument for Shapes.AddPolyline ?  I used the following code but get an out of range exception.

    Any help would be greatly appreciated.

     

    int[,] myPoints = new int[5,2];  // {500,50,505,55,510,60,515,65,520,70};

                myPoints[0, 0] = 500;

                myPoints[0, 1] = 50;

                myPoints[1, 0] = 505;

                myPoints[1, 1] = 55;

                myPoints[2, 0] = 510;

                myPoints[2, 1] = 60;

                myPoints[3, 0] = 515;

                myPoints[3, 1] = 65;

                myPoints[4, 0] = 520;

                myPoints[4, 1] = 70;

                object points = myPoints;

                myShape = myWordDocument.Shapes.AddPolyline(ref points, ref missing);

    Wednesday, May 18, 2011 6:50 PM

Answers

  • I tried to perform this code and I think it's successful.

     private void ThisDocument_Startup(object sender, System.EventArgs e)
        {
          Single[,] myPoints = new Single[5, 2]; // {500,50,505,55,510,60,515,65,520,70};
          //int[,] myPoints = new int[5, 2]; 
    
          myPoints[0, 0] = 500;
    
          myPoints[0, 1] = 50;
    
          myPoints[1, 0] = 505;
    
          myPoints[1, 1] = 55;
    
          myPoints[2, 0] = 510;
    
          myPoints[2, 1] = 60;
    
          myPoints[3, 0] = 515;
    
          myPoints[3, 1] = 65;
    
          myPoints[4, 0] = 520;
    
          myPoints[4, 1] = 70;      
    
          object po = myPoints;
          
          this.Shapes.AddPolyline(ref po, ref missing);
          
          //same Result
          //this.Shapes.AddLine(500, 50, 520, 70, ref missing);
    
        }
    

    http://vsto.tistory.com
    • Proposed as answer by Bruce Song Tuesday, May 24, 2011 7:10 AM
    • Marked as answer by Bruce Song Tuesday, May 31, 2011 10:20 AM
    Friday, May 20, 2011 12:47 AM