C# - Interop.word - change picture horizontal and vertical alignment RRS feed

  • General discussion

  • I am using Microsoft.Office.Interop.Word to generate reports in my application. 

    I am inserting images (charts) which are generated based on data.

    These images are bigger in size hence they do not fit into the Word document properly. 

    If I reduce the size of the images to fit them in document, they became blur.

    When i made the position "Position in Top Center with Square Text Wrapping" and rotate the image by "Right 90", the images are best fitted in the document. This I tried in Word to see how image will look.

    But I am unable to find a solution in C# to do this.

    The code is given below.

    using Word = Microsoft.Office.Interop.Word;

            private object oMissing = System.Reflection.Missing.Value;
            private Word._Application wordApplication;
            private Word._Document wordDocument;

            private object oEndOfDoc = "\\endofdoc";

    Word.Range wrdRange = wordDocument.Bookmarks.get_Item(ref oEndOfDoc).Range;
                wrdRange.ParagraphFormat.Alignment = imageAlignment;
                wrdRange.InsertAfter(Environment.NewLine + imageTitle);

                Object oLinkToFile = false;  //default
                Object oSaveWithDocument = true;//default

                Word.InlineShape imageInserted = wordDocument.InlineShapes.AddPicture(imagePath, ref oLinkToFile, ref oSaveWithDocument, wrdRange);
                imageInserted.ScaleHeight = imageInserted.ScaleWidth = (float)100.00;

    Please suggest me some change to make position  "Position in Top Center with Square Text Wrapping" and rotate the image by "Right 90".


    Thursday, April 19, 2012 5:31 AM

All replies

  • Hi Mukul_DOW,

    As far as I know, Word 2010 doesn't expose the method or properties for us to process the pictures. Thank you for your understanding.

    Best Regards,

    Bruce Song [MSFT]
    MSDN Community Support | Feedback to us

    • Edited by Bruce Song Friday, April 20, 2012 6:49 AM
    Friday, April 20, 2012 6:49 AM