adding pictures to the end of a word document?!

W

Webtechie

Hello,

I've been able to code the following from Excel VBA (2007)

1) open a Word template
2) Update some bookmarks
3) Add pictures from a folder into word


However, the picutres are being added at the beginning of the document.
After updating the bookmarks, I'd like to go to the end of the document and
add the picture.

The pictures are tiling on top of each other. I'm not sure why.

Here is my current code:


mPatientID = wks.Range("c15").Value
mExamName = wks.Range("c25").Value
lrow = wks.Range("ba1").End(xlDown).Row

Set wrdApp = CreateObject("word.application")
'open the template to populate

sPath = ThisWorkbook.path & "\"
reviewFileLetterSave = sPath & reviewFileLetter
Set wrdDoc = wrdApp.Documents.Add(Template:=sPath & _
"formlettertmp.dot")


With wrdDoc


..Bookmarks("PatientID").Range.Text = mPatientID
..Bookmarks("ExamName").Range.Text = mExamName
For i = 0 To lrow - 1
mComment = wks.Range("bb1").Offset(i, 0).Value
mPageName = wks.Range("ba1").Offset(i, 0).Value
.Content.InsertAfter mComment
.Content.InsertParagraphAfter
For x = 1 To 3
imagefile = sFolder & "\images\" & reviewfileName & "_" &
mPageName & "_ch" & CStr(x) & ".gif"

.Content.InsertParagraphAfter
.Content.InlineShapes.AddPicture _
Filename:=imagefile, _
LinkToFile:=False, SaveWithDocument:=True
Next x
Next i
If Dir(reviewFileLetterSave) <> "" Then
Kill reviewFileLetterSave
End If
.SaveAs (reviewFileLetterSave)
.Close ' close the document
End With

'populate the bookmarks
'

Set wrdDoc = Nothing

'close word
wrdApp.Quit
Set wrdApp = Nothing
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top