Inserting multiple images from a unique URL to a word document via VBA

I am trying to put together a macro that will insert multiple images into a 3 column table of a new Word document. The images themselves are from a website URL, the URL which is concatenation of a URL and the data in column A.

Row 1 of my workbook is all headings. The URL I am using is "http://qrcode.kaywa.com/img.php?s=8&d=" with the value of Column A, starting at A2 and working its way down (to the last value).

As an example, A2 contains the data 1-85858, so the URL image will be http://qrcode.kaywa.com/img.php?s=8&d=1-85858.

In addition, I would like to be able to insert below each image the data that is respective Columns B and C (First and Last Name).

I've done some work on it and am having difficulties getting all of the images into one word document.

The Word document itself doesn't have to save anywhere, can be saved by the user later on.

I appreciate any assistance.

Retrieve Internet Images

Hi

trying pasting the code below in a module.
you also need tro retrieve the modDownloadFile form www.cpearson.com developed by Chip

Dim WordApp
Dim WordDoc
Sub excelexperts_image_download()
0: ' By IT Friend, as an answer to following thread :
1: ' http://excelexperts.com/inserting-multiple-images-unique-url-word-docume...
2: ' The modDownloadFile module from Chip Pearson is needed to run the procedure DownloadFile
Dim s_destinationfilename As String ' for the filename to be written.
Dim s_UrlFileName As String ' for the file to be retrieved.

' Loop on active worksheet records, based on column A.
For Each cl In Range("A1", Range("A" & Rows.Count).End(xlUp))

' Get the file to be retrieved
s_UrlFileName = cl.Text

' Build the filename to be written.
s_destinationfilename = "c:\Image_Ligne_" & cl.Row & ".jpeg"

' Retrieve the file.
Call DownloadFile(s_UrlFileName, s_destinationfilename, True, "Error for file " & s_UrlFileName)

Next cl

Call excelexperts_build_word_document
End Sub
Sub excelexperts_build_word_document()
0: ' By IT Friend, as an answer to following thread :
1: ' http://excelexperts.com/inserting-multiple-images-unique-url-word-docume...

Dim s_destinationfilename As String
Dim i As Long
i = 1
Call Word_Get_Reference ' Get or open word
WordApp.Visible = True ' Display Word
WordApp.Documents.Add ' Create a new document
Set WordDoc = WordApp.ActiveDocument ' Store in object variable the newly added document

' Add a table
WordDoc.Tables.Add Range:=WordDoc.Range, NumRows:=1, NumColumns:= _
3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed

' Set the table style
Call Word_Table_Style

' Populate its header's cells
WordDoc.Tables(1).cell(1, 1) = "Field 1"
WordDoc.Tables(1).cell(1, 2) = "Field 2"
WordDoc.Tables(1).cell(1, 3) = "Field 3"

For Each cl In Range("A1", Range("A" & Rows.Count).End(xlUp))
i = i + 1
WordApp.Selection.InsertRowsBelow 1
WordDoc.Tables(1).cell(i, 1).Range.InsertAfter cl.Offset(, 1).Text
WordDoc.Tables(1).cell(i, 2).Range.InsertAfter cl.Text
'WordDoc.Tables(1).cell(i, 3).Range.Select
' Selection.InlineShapes.AddPicture Filename:="C:\F06.png", LinkToFile:= _
False, SaveWithDocument:=True

' Check if file has been built
s_destinationfilename = "c:\Image_Ligne_" & cl.Row & ".jpeg"
If Dir(s_destinationfilename, vbNormal) = "" Then
WordDoc.Tables(1).cell(i, 3).Range.InsertAfter "Non rapatrié"
Else
WordDoc.Tables(1).cell(i, 3).Range.InlineShapes.AddPicture Filename:=s_destinationfilename, LinkToFile:= _
False, SaveWithDocument:=True
End If
Next cl
End Sub
Sub Word_Get_Reference()
0: ' Getting MS Word instance, if failure, open a new instance.
1: ' By IT Friend, as an answer to following thread :
2: ' http://excelexperts.com/inserting-multiple-images-unique-url-word-docume...

On Error GoTo NoCurrentWord 'if Word isn't open, jump to this label.
Set WordApp = GetObject(Class:="Word.Application") 'try to get a reference to running copy of Word.
Exit Sub 'if we get here, Word was open ==> can leave.

NoCurrentWord:
Set WordApp = CreateObject(Class:="Word.Application") 'if we get here, Word wasn't open - so open a new instance.
End Sub
Sub Word_Table_Style()
With WordDoc.Tables(1)
If .Style <> "Table Grid" Then
.Style = "Table Grid"
End If
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
.ApplyStyleRowBands = True
.ApplyStyleColumnBands = False
End With
End Sub