PC Review


Reply
Thread Tools Rate Thread

adding pictures to the end of a word document?!

 
 
Webtechie
Guest
Posts: n/a
 
      20th Feb 2009
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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
pictures from word 2003 document wont appear in word 2007 =?Utf-8?B?UGV0ZXdhbGw=?= Microsoft Word Document Management 9 6th Dec 2007 02:48 AM
Adding pictures to word document Katie Microsoft Word Document Management 1 1st Nov 2005 02:02 AM
Why can't I put pictures in a Word document? =?Utf-8?B?TWljaGVsbGU=?= Microsoft Word Document Management 1 17th Oct 2005 01:20 AM
how do i get pictures off of a word document? =?Utf-8?B?U2NobGVl?= Microsoft Word Document Management 3 18th May 2005 01:31 PM
Adding pictures to word processor document =?Utf-8?B?d2VuemVs?= Windows XP New Users 2 16th Dec 2004 05:54 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:14 AM.