QTP Forums

Full Version: Sequence of Writing to Word document
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello,
I take screenshots and write them to word documents. When I add the second screenshot it is added in the first page and the image in the first page is moved to the second page. Is there a way to add an image at in the second page ? In other words I want to add new pages in Word at the bottom of the current page (not on the top)

Code:
Dim Wrd
                                        Dim WrdDoc
                                        Const Wrdalignpgraphleft=1
                                        Set Wrd=CreateObject("Word.Application")
                                        Const wdOrientLandscape = 1
                                        Wrd.Visible=False
                                        Set WrdDoc=Wrd.Documents.Open (WordDocumentName , False)
                                        Set Selection = Wrd.Selection
                                        Selection.TypeText Comment & " --  Test Executed : "&NOW
                                        Selection.TypeParagraph
                                        WrdDoc.Range.Select
                                        WrdDoc.Range.Select
                                                                                                    
                                                            With Wrd.ActiveDocument.PageSetup
                                                                        .Orientation = wdOrientLandscape
                                                                            .TopMargin = Wrd.InchesToPoints(0.92)
                                                                                .BottomMargin = Wrd.InchesToPoints(0.92)
                                                                                    .LeftMargin = Wrd.InchesToPoints(0.30)
                                                                                        .RightMargin = Wrd.InchesToPoints(0.5)
                                                                                            .PageWidth = Wrd.InchesToPoints(12)
                                                                                                .PageHeight = Wrd.InchesToPoints(10)
                                                            End With
                                                            
                                        Set img= WrdDoc.InlineShapes.AddPicture(ConfirmationBMP, True)
                                        img.Width=img.Width*1
                                        img.Height=img.Height*1
                                        img.range.paragraphformat.Alignment=Wrdalignpgraphcenter
                                        WrdDoc.Save
                                        WrdDoc.close
                                        Wrd.Quit
                                        Set Wrd=nothing
                                        Set WrdDoc=nothing
                                        Set WrdDocsel=nothing
                                        Set img=nothing

Thanks,
Raj
after each time when you write in the doc you can insert a pagebreak there
Code:
Const wdPageBreak = 7
Selection.InsertBreak(wdPageBreak)

does this help?
Saket,
Thanks for the suggestion. The state creates a page break, but dose not accomplish the desired result.

Thanks,
Raj
Reference URL's