I am trying to open an existing word file and insert image into it (image name with path being passed to the function ).
Code logic is working fine but challenge is every time the new image file is inserting / place on the top of the last one.mean the latest image is displaying on very first page of the word file and the rest are accordingly. But my objective is the oldest one will be on top.Or you can say the 1st one will palace 1st and the after that 2nd ,3rd .....
Here is my code sample.
using WordC = Microsoft.Office.Interop.Word;
public void insertImage(string docFileName, string imgFilename)
{
WordC.Application wordApp = new WordC.Application();
// create Word document object
WordC.Document aDoc = null;
object readOnly = false;
object isVisible = false;
wordApp.Visible = false;
// wordApp.DisplayAlerts = false;
aDoc = wordApp.Documents.Open(docFileName, Type.Missing, ref readOnly,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing, ref isVisible, Type.Missing,
Type.Missing, Type.Missing, Type.Missing);
aDoc.Activate();
// WordC.Document doc = WordApp.Documents.Open(docFileName);
// now add the picture in active document reference
aDoc.InlineShapes.AddPicture(imgFilename, Type.Missing, Type.Missing, Type.Missing);
aDoc.Save();
aDoc.Close(Type.Missing, Type.Missing, Type.Missing);
wordApp.Quit(Type.Missing, Type.Missing, Type.Missing);
}