Monday, June 14, 2010

QTP Powerpoint Automation (VBScript)-3

'OPENING an already existing PPT file, ADDING a slide, WRITING tilte & text to the slide, SAVING and CLOSING the PPT

Set obj_ppt = CreateObject("PowerPoint.Application")
obj_ppt.visible=True
Set obj_Pre = obj_ppt.Presentations.Open("c:\untitled.ppt")
Set obj_Slide = obj_Pre.Slides.Add(2,2)
‘Using the TextFrame property to return the TextFrame object for a shape. The TextRange property ‘returns a TextRange object that represents the range of text inside the specified text frame.
obj_Slide.Shapes(1).TextFrame.TextRange.Text ="Title Goes Here"
obj_Slide.Shapes(2).TextFrame.TextRange.Text ="Text Goes Here, Text Goes Here, Text Goes Here"
obj_Pre.SaveAs("C:\untitled.ppt")
obj_Pre.Close
obj_ppt.Quit




















Also See:
1. Opening a new PPT, adding a picture into it, saving it and closing the PPT
2. OPENING a new PPT, ADDING a title & text into it, SAVING the PPT file and CLOSING it.
3. OPENING a new PPT, ADDIND a blank slide to it, ADDING table, ENTERING text, SAVING & CLOSING PPT
4. Creating a chart in Powerpoint & manipulating it