Export picturebox image to word

Hello ,
How can i export picturebox images to word document.

Regards
RIASAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hello ThereSystem AdministratorCommented:
There are many sample codes you can edit and use.
E.g. here.

Example:
Imports Microsoft.Office.Interop
Dim word_app As Word._Application = New  _
Word.ApplicationClass()

  ' Create the Word document.
Dim word_doc As Word._Document = _
word_app.Documents.Add()

Dim para As Word.Paragraph = word_doc.Paragraphs.Add()
para.Alignment = Word.WdParagraphAlignment.wdAlignParagraphCenter
para.Range.InlineShapes.AddPicture("C:\images\image.png")
para.Range.InsertParagraphAfter()
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RIASAuthor Commented:
Thanks, will try and brb
0
RIASAuthor Commented:
Thanks,

I have a merge document. Need to add image where te merge field is <<srce>>.
So far my code is
  Dim objWordApp As Word.Application
            objWordApp = New Word.Application
            Dim objDoc As Word.Document

            objWordApp.Documents.Open("C:\Users\PhotoTemplate.doc")
            objDoc = objWordApp.ActiveDocument

            'Open an existing document.

            objDoc.Content.Find.Execute(FindText:="<<srce>>",
ReplaceWith:="test",
Replace:=Word.WdReplace.wdReplaceAll) ''''''
            Dim oldbitmap As Bitmap = New Bitmap(Me.PicDriver.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 = "C:\Users\admin.anu\Downloads\PhotoTemplate"
            newbitmap.Save(pathToSavedImage, Imaging.ImageFormat.Bmp)
            oldbitmap.Dispose()
            newbitmap.Dispose()
            g.Dispose()

            Dim ObjPic As Microsoft.Office.Interop.Word.InlineShape = objDoc.InlineShapes.AddPicture(pathToSavedImage)
            'Dim oldCopy As String
            'oldCopy = ("" & Form2.TextBox1.Text & "\" & Form1.TextBox1.Text & ".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

            'Code to be tested

Open in new window

0
RIASAuthor Commented:
Thanks
0
Hello ThereSystem AdministratorCommented:
I am glad I could help even if I am not VB guru. :D
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.