Friday, April 9, 2010

VBScript - How Can I Copy Data from Excel to PowerPoint?

VBScript - How Can I Copy Data from Excel to PowerPoint?

Const ppPasteOLEObject = 10
Const ppLayoutBlank = 12

Set objExcel = CreateObject("Excel.Application")
objExcel.Visible = True

Set objWorkbook = objExcel.Workbooks.Open("C:\Scripts\Test.xls")

Set objWorksheet = objWorkbook.Worksheets(1)
objWorksheet.Activate

Set objRange = objWorkSheet.UsedRange
objRange.Copy

Set objPPT = CreateObject("PowerPoint.Application")
objPPT.Visible = True

Set objPresentation = objPPT.Presentations.Add
Set objSlide = objPresentation.Slides.Add(1,1)

objPresentation.Slides(1).Layout = ppLayoutBlank
objPPT.Windows(1).View.PasteSpecial ppPasteOLEObject

objExcel.Quit

[Via]