Micro Focus QTP (UFT) Forums
Sequence of Writing to Word document - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: Sequence of Writing to Word document (/Thread-Sequence-of-Writing-to-Word-document)



Sequence of Writing to Word document - Raj20091 - 12-03-2009

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


RE: Sequence of Writing to Word document - Saket - 12-03-2009

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?


RE: Sequence of Writing to Word document - Raj20091 - 12-03-2009

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

Thanks,
Raj