psctornado
09-15-2014, 10:11 AM
Hi All,
Hope your all having a great day. I need a little help on inserting an image on a specific page. Currently I have image 'Dog' inserting where it should, at the top of the document of the 1st page. However, I would like to have the image 'Cat' be inserted after my 'Page Break' code. Instead what my code seems to be doing is inserting both 'Dog' & 'Cat' in the same page and same row.
Would anyone be able to help. Below is an abbreviated code from my workbook.
D104 = Cat
B5 = Dog
Any help would be greatly appreciated!!
Thanks!!!!!
Private Sub cmdTrigLitAP_Click()
Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
' Tell Word to create a new document
appWD.Documents.Add
' Document entered
appWD.Selection.Font.Size = 11
appWD.Selection.Font.Name = "Times New Roman"
appWD.Selection.PageSetup.TopMargin = InchesToPoints(1)
appWD.Selection.PageSetup.LeftMargin = InchesToPoints(1)
appWD.Selection.PageSetup.RightMargin = InchesToPoints(1)
With appWD.Selection.ParagraphFormat
.RightIndent = InchesToPoints(0)
.LeftIndent = InchesToPoints(0)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
If (Dir("I:\Dog.jpg") = "") Then
FileCopy "C:\\Users\Documents\Dog.jpg", "I:\Dog.jpg"
End If
appWD.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
appWD.Selection.Font.Bold = True
appWD.Selection.TypeText Text:=Sheet15.Range("AB1")
appWD.Selection.TypeParagraph
appWD.Selection.Font.Bold = False
appWD.Selection.TypeText Text:=Sheet15.Range("AB2")
appWD.Selection.TypeParagraph
appWD.Selection.TypeText Text:=Sheet15.Range("AB3")
appWD.Selection.TypeParagraph
appWD.Selection.Font.Bold = True
appWD.Selection.TypeText Text:=Sheet15.Range("AB4")
appWD.Selection.TypeParagraph
appWD.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
appWD.Selection.TypeText Text:=Sheet15.Range("A7")
appWD.Selection.TypeParagraph
appWD.Selection.TypeText Text:=Sheet15.Range("A8")
appWD.Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.25), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
appWD.Selection.TypeText Text:=vbTab & Sheet15.Range("V9")
appWD.Selection.TypeParagraph
appWD.Selection.InsertBreak Type:=wdPageBreak
If (Dir("I:\About.jpg") = "") Then
FileCopy "C:Users\Documents\Cat.JPG.jpg", "I:\Cat.jpg"
End If
appWD.Selection.TypeParagraph
appWD.Selection.TypeText Text:=Sheet15.Range("A60")
appWD.Selection.TypeParagraph
appWD.ActiveDocument.Shapes.AddPicture "I:\" & Sheet11.Range("D104") & ".jpg", False, True, 0, 0
appWD.ActiveDocument.Shapes.AddPicture "I:\" & Sheet11.Range("B5") & ".jpg", False, True, 0, 0
End Sub
Hope your all having a great day. I need a little help on inserting an image on a specific page. Currently I have image 'Dog' inserting where it should, at the top of the document of the 1st page. However, I would like to have the image 'Cat' be inserted after my 'Page Break' code. Instead what my code seems to be doing is inserting both 'Dog' & 'Cat' in the same page and same row.
Would anyone be able to help. Below is an abbreviated code from my workbook.
D104 = Cat
B5 = Dog
Any help would be greatly appreciated!!
Thanks!!!!!
Private Sub cmdTrigLitAP_Click()
Dim appWD As Word.Application
Set appWD = CreateObject("Word.Application")
appWD.Visible = True
' Tell Word to create a new document
appWD.Documents.Add
' Document entered
appWD.Selection.Font.Size = 11
appWD.Selection.Font.Name = "Times New Roman"
appWD.Selection.PageSetup.TopMargin = InchesToPoints(1)
appWD.Selection.PageSetup.LeftMargin = InchesToPoints(1)
appWD.Selection.PageSetup.RightMargin = InchesToPoints(1)
With appWD.Selection.ParagraphFormat
.RightIndent = InchesToPoints(0)
.LeftIndent = InchesToPoints(0)
.SpaceBeforeAuto = False
.SpaceAfterAuto = False
End With
If (Dir("I:\Dog.jpg") = "") Then
FileCopy "C:\\Users\Documents\Dog.jpg", "I:\Dog.jpg"
End If
appWD.Selection.ParagraphFormat.Alignment = wdAlignParagraphRight
appWD.Selection.Font.Bold = True
appWD.Selection.TypeText Text:=Sheet15.Range("AB1")
appWD.Selection.TypeParagraph
appWD.Selection.Font.Bold = False
appWD.Selection.TypeText Text:=Sheet15.Range("AB2")
appWD.Selection.TypeParagraph
appWD.Selection.TypeText Text:=Sheet15.Range("AB3")
appWD.Selection.TypeParagraph
appWD.Selection.Font.Bold = True
appWD.Selection.TypeText Text:=Sheet15.Range("AB4")
appWD.Selection.TypeParagraph
appWD.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
appWD.Selection.TypeText Text:=Sheet15.Range("A7")
appWD.Selection.TypeParagraph
appWD.Selection.TypeText Text:=Sheet15.Range("A8")
appWD.Selection.ParagraphFormat.TabStops.Add Position:=InchesToPoints(6.25), _
Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
appWD.Selection.TypeText Text:=vbTab & Sheet15.Range("V9")
appWD.Selection.TypeParagraph
appWD.Selection.InsertBreak Type:=wdPageBreak
If (Dir("I:\About.jpg") = "") Then
FileCopy "C:Users\Documents\Cat.JPG.jpg", "I:\Cat.jpg"
End If
appWD.Selection.TypeParagraph
appWD.Selection.TypeText Text:=Sheet15.Range("A60")
appWD.Selection.TypeParagraph
appWD.ActiveDocument.Shapes.AddPicture "I:\" & Sheet11.Range("D104") & ".jpg", False, True, 0, 0
appWD.ActiveDocument.Shapes.AddPicture "I:\" & Sheet11.Range("B5") & ".jpg", False, True, 0, 0
End Sub