none
Set Image position Absolute position (text through) in MS word using VB.Net code RRS feed

  • Question

  • I have been trying an image have an absolute position in Microsoft word using the following vb.net code: 

    logoimg = Doc.Content.Paragraphs.Add
    logoimg.Range.Paragraphs.Alignment = WdParagraphAlignment.wdAlignParagraphJustifyHi
    logoimg.Range.InlineShapes.AddPicture(Environment.CurrentDirectory & "\Common\logo.jpg")

    can any one tell me what should be the next line(s) of code to make this image's position absolute?

    How can I set the absolute position of an image with top and left set to 0 

    Any help would be very appreciated!

    Friday, March 27, 2015 1:49 PM

Answers

  • Hi,

    There isn’t the position (Top, Left etc) property in the InlineShape object, however there are the Top and Left properties in the Shape object.

    So, I suggest that you could convert the InlineShape to Shape object (ConvertToShape method), then change the position.

    Also, we also could change the Shape object to InlineShape (ConverToInlineShape method).

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 30, 2015 5:53 AM
    Moderator

All replies

  • Check the Shapes class, it has more options for the position:

    https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.shapes.addpicture(v=office.14).aspx?cs-save-lang=1&cs-lang=vb#code-snippet-1

    https://msdn.microsoft.com/en-us/library/ms178792.aspx?cs-save-lang=1&cs-lang=vb#code-snippet-5

    And regarding the InlineShapes you can use the range parameter(after defining a Range object), check this article describing the range argument functionality:

    https://msdn.microsoft.com/en-us/library/microsoft.office.interop.word.inlineshapes.addpicture.aspx


    Fouad Roumieh

    Sunday, March 29, 2015 5:08 AM
  • Hello,

    Since this is about MS-Word I am moving your question to the Word for developers forum which will have more people there experienced with working with Word.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

    Sunday, March 29, 2015 10:50 AM
  • Hi,

    There isn’t the position (Top, Left etc) property in the InlineShape object, however there are the Top and Left properties in the Shape object.

    So, I suggest that you could convert the InlineShape to Shape object (ConvertToShape method), then change the position.

    Also, we also could change the Shape object to InlineShape (ConverToInlineShape method).

    Regards

    Starain


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 30, 2015 5:53 AM
    Moderator