title: Inserting a picture to a word document
body: <p>Hi I wish to insert an image form a picturebox into a .doc file. I am able to get the image into the file and it saves correctly but I am having trouble with the placement of the image. I want to have the image in a table that exists on the template .doc but it always ends up in the first cell on the first table.</p>
  
  <pre><code>    Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
          Dim objWordApp As Word.Application
          objWordApp = New Word.Application
          Dim objDoc As Word.Document
  
          objWordApp.Documents.Open("" &amp; Form2.TextBox1.Text &amp; "\capatext\temlate.doc")
          objDoc = objWordApp.ActiveDocument
  
          'Open an existing document.
  
  
          objDoc.Content.Find.Execute(FindText:="&lt;&lt;srce&gt;&gt;", _
  ReplaceWith:=Form1.TextBox15.Text, _
  Replace:=Word.WdReplace.wdReplaceAll) ''''''
          Dim oldbitmap As Bitmap = New Bitmap(Form1.PictureBox1.Image)
          Dim newbitmap As Bitmap = New Bitmap(CInt(100%), CInt(100%))
          Dim g As Graphics = Graphics.FromImage(newbitmap)
          g.DrawImage(oldbitmap, 0, 0, newbitmap.Width, newbitmap.Height)
          Dim pathToSavedImage As String = "" &amp; Form2.TextBox1.Text &amp; "\capatext\tempimg1.jpg"
          newbitmap.Save(pathToSavedImage)
          oldbitmap.Dispose()
          newbitmap.Dispose()
          g.Dispose()
  
          Dim ObjPic As Microsoft.Office.Interop.Word.InlineShape = objDoc.InlineShapes.AddPicture(pathToSavedImage)
          Dim oldCopy As String
          oldCopy = ("" &amp; Form2.TextBox1.Text &amp; "\" &amp; Form1.TextBox1.Text &amp; ".doc")
          If System.IO.File.Exists(oldCopy) = True Then
              System.IO.File.Delete(oldCopy)
          ElseIf System.IO.File.Exists(oldCopy) = False Then
          End If
          objWordApp.Quit()
          objWordApp = Nothing
          Timer1.Start()
      End Sub
  </code></pre>