none
Word 2007 - Creating shapes in VSTO RRS feed

Answers

  • Hi abram

    NO.

    The Office type libraries aren't designed to work that way. You need to "add" things to an existing "design surface" (in Word's case, a document) before you can do anything with them.

    Some of the very newest object models in Office 2010 are designed to be used in the way to which you are accustomed: create the object, format it, then assign it to the document surface. But nothing like this in Word 2007.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by theabram2 Wednesday, September 1, 2010 7:58 AM
    Tuesday, August 31, 2010 3:46 PM
    Moderator

All replies

  • Hi abram

    NO.

    The Office type libraries aren't designed to work that way. You need to "add" things to an existing "design surface" (in Word's case, a document) before you can do anything with them.

    Some of the very newest object models in Office 2010 are designed to be used in the way to which you are accustomed: create the object, format it, then assign it to the document surface. But nothing like this in Word 2007.


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by theabram2 Wednesday, September 1, 2010 7:58 AM
    Tuesday, August 31, 2010 3:46 PM
    Moderator
  • Hi - this was a while back - but

    How do you do it in Office 2010

    I need to set shape width and height before placing it in the document - since I still want the Picture to be at it's original high resolution - just scaled in the shape

    The problem is

    ---------------------------------------------------------------------------------

    //get the target width

    Microsoft.Office.Interop.Word.Cells cells = selection.Cells;

    foreach (Microsoft.Office.Interop.Word.Cell cell in cells)
         {
             //indexedCell.Cell...
             cellWidth = cell.Width;
             targetWidth = cellWidth - 10;
             Debug.WriteLine("cell.Width: " + targetWidth);//this is what you need.
         }

    //placing the shape in the document - at the selected cell location in a table

    myShape = selection.InlineShapes.AddPicture(filePath, true, true, selection).ConvertToShape();

    myShape.Width = targetWidth;
                    myShape.Height = targetHeight;

    myShape.WrapFormat.Type = Word.WdWrapType.wdWrapInline;

    ---------------------------------------------------------------------------------

    this messes up my table-Column and Cell width

    the picture in the next ROW will test a wider CELL - width - since the picture has forced the cell widerWhen I place the image it is LARGE for a split second then reduces to size and wraps - but it l

    There is also a JUMP in the size of the Column parent leaving the column wider after-wards

    Ideally I would like to apply the shape size and format in memory first before moving it onto the page

    any ideas appreciated

    Thanks

    Thursday, August 22, 2013 6:59 AM