How to Use VB.NET Insert Image into Word Document?

Posted by Cc9530 under VB.NET on 1/26/2011 | Points: 10 | Views : 25875 | Status : [Member] | Replies : 4
To insert image into Word document there comes with serveral easy methods in Microsoft Word. The easiest way is directly from Windows Explorer by dragging and dropping the image into your Word doucument. What you need to do is open your Microsoft Office Word document, drag the image you want from the Web page into your Word document. Yes, that's it. You also can right-click the image you want and click "Copy", and in your Word document, click "paste" to insert the image at where you want.

If you want to insert an image from a file, you can use Microsoft Office Word's insert function. Open your Word document, choose the place you want to insert the image. On the Insert menu, select picture option, click From File. Choose the image you want to insert in your file and double-click.

You can directly insert an image into your Word document from a scanner or digital camera either. In this procedure, you need to make sure your device is TWAIN- or WIA- compatible and is connected to your computer. In addition, you should also ensure you have installed the software that supports TWAIN or WIA.

Acctually, you also can insert image into Word document by using Spire.Doc for .NET through C#/VB.NET code.
How to Use Spire.Doc for .NET to Insert Image into Word Document?
Spire.Doc presents you an easiest way to insert an image into the word document, you may simply use paragraph.AppendPicture(Image.FromFile("Image.jpg")) method to load a image from file. Something must be paid attention, if you use the method above, you should put your image under the folder of "Debug". Otherwise, you should give the path like: @"............DataImage.jpg". You can set the format with paragraph.Format.HorizontalAlignment property.
Use the VB.NET code of Spire.Doc for .NET below to insert image into Word document:

01 Imports System.Drawing

02 Imports Spire.Doc

03 Imports Spire.Doc.Documents


05 Module Module1


07 Sub Main()

08 'Create word document

09 Dim document As New Document()


11 'Create a section

12 Dim section As Section = document.AddSection()


14 'Add a image paragraph

15 Dim paragraph As Paragraph = section.AddParagraph()


17 'Set the format of the image paragraph

18 paragraph.Format.HorizontalAlignment = Spire.Doc.Documents.HorizontalAlignment.Left


20 'Load a image file

21 paragraph.AppendPicture(Image.FromFile("Image.jpg"))


23 'Save doc file.

24 document.SaveToFile("Sample.doc", FileFormat.Doc)


26 'Launch the file.

27 System.Diagnostics.Process.Start("Sample.doc")

28 End Sub

29 End Module

i could be the one


Posted by: Sagarp on: 1/26/2011 [Member] Bronze | Points: 25

Public Function PictureInsert()

On Error Resume Next
Dim oDoc As Word.Document
Dim range As Word.Range

oDoc = GetObject(strIniFileName)
LinkToFile:=False, SaveWithDocument:=True) '<- this park doesn't work

'Save Document
oDoc.SaveAs(Filename:=strIniSave & "\" & "outCome2" & ".doc")

'close the word Document, App still open
oDoc = Nothing
Exit Function
MessageBox.Show("file missing.")
End Function


Cc9530, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thackeray on: 3/11/2014 [Member] Starter | Points: 25

Sometime, we need to add and insert image into Word page programmatically without having any dependency on Microsoft Office tools, and want to burn an image on desired location of source Word page. This time, we have to use and apply a Word image adding tool:

Private Sub AddImage(img As REImage, positionX As Single, positionY As Single, compression As WordCompression) Implements DOCXPage.AddImage
End Sub

Cc9530, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Thomas128 on: 3/12/2014 [Member] Starter | Points: 25

Hi, here's a guide I found to help you insert or draw an image in Word doc

Today is a gift. That's why it's called the Present!

Cc9530, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Mattyclown on: 6/5/2014 [Member] Starter | Points: 25

wrong post

Cc9530, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response