locked
Insert Image at user selected cursor or current position RRS feed

  • Question

  • Dear All, 

    I am using the following code where i am trying to insert an image at current position or where event the user cursor is currently there but always it insert it on top of the word document can anyone please guide the missing bit: 

     Microsoft.Office.Interop.Word._Application oWord;
                object oMissing = Type.Missing;
                oWord = new Microsoft.Office.Interop.Word.Application();
                oWord.Visible = false;
                oWord.Documents.Open(rtffile);
                
                
                
          
                string arrowpath = SMBytepath + "\\Arrow Final.png";
                _ = oWord.Selection.InlineShapes.AddPicture(arrowpath).ConvertToShape().WrapFormat.AllowOverlap;
                oWord.Selection.Select();
    
                oWord.ActiveDocument.Save();
                oWord.Quit();


    MAzeem

    Thursday, November 19, 2020 4:00 PM

All replies

  • forum migrated to mentioned below link please use this

    https://docs.microsoft.com/en-us/answers/index.html

     hope answer the question if issue resolve please accept answer

    Friday, November 20, 2020 8:04 PM
  • From the code you have shared, it appears you are always starting a new instance of Word and then opening a document. On a document open the current insertion point will always be at the top of the document.

    Your function should not be opening a new instance of Word every time it executes, and it should not a opening the document. If you want to insert a picture into a document that the end user is currently editing then the routine should be assigning the active document to a variable and then using this variable, insert the picture where the user has the current insertion point.


    Kind Regards, Rich ... http://greatcirclelearning.com

    Wednesday, December 2, 2020 1:02 AM