I'm working on a macro that includes a bunch of links to image files. I want to be able to select a given row in the document and have it insert that image into a word document. I have it working to an extent, but I can't get the images to be placed at end of document like I want.
With my current code I run one macro to create the document with a heading that includes the title of the quiz and a spot for the student's name.
Then I select the row for first image and run a second macro. The image file is inserted, but it is at the top of the document pushing the text down. When I continue to add pictures they are all added at the top pushing everything else down.
How can I fix this so that the image is inserted at the bottom?
With my current code I run one macro to create the document with a heading that includes the title of the quiz and a spot for the student's name.
Then I select the row for first image and run a second macro. The image file is inserted, but it is at the top of the document pushing the text down. When I continue to add pictures they are all added at the top pushing everything else down.
How can I fix this so that the image is inserted at the bottom?
Code:
Dim wrdApp
Dim wrdDoc
Sub CreateSheet()
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.documents.Add ' create a new document
With wrdDoc
'.Selection.Style = .ActiveDocument.Styles("Title")
.Content.InsertAfter Text:=InputBox("What is the name of document?", "Name", "MCQ Practice")
.Content.InsertParagraphAfter
.Content.ParagraphFormat.Alignment = wdAlignParagraphRight
.Content.InsertAfter Text:="Name ______________"
End With
End Sub
Sub InsertQuestion()
wrdApp.Visible = True
' filename and directory stored in column L
file = Range("a1").Offset(ActiveCell.Row - 1, 11)
With wrdDoc
.Content.InlineShapes.AddPicture Filename:=file, LinkToFile:=False, SaveWithDocument:=True
.Content.InsertParagraphAfter
End With
End Sub