Sub CreatePowerPointTable()
Dim oPPTApp As PowerPoint.Application
Dim oPPT As PowerPoint.Presentation
Dim oSlide As PowerPoint.Slide
Dim oTable As PowerPoint.Table
Dim oWS As Worksheet
Dim lMaxRow As Long
Dim lRow As Long
Dim lMaxCol As Long
Dim lCol As Long
Set oWS = Worksheets(1)
lMaxRow = oWS.Cells.SpecialCells(xlCellTypeLastCell).Row
lMaxCol = oWS.Cells.SpecialCells(xlCellTypeLastCell).Column
Set oPPTApp = New PowerPoint.Application
oPPTApp.Visible = True
Set oPPT = oPPTApp.Presentations.Add
Set oSlide = oPPT.Slides.Add(1, ppLayoutBlank)
Set oTable = oSlide.Shapes.AddTable(lMaxRow, lMaxCol).Table
For lRow = 1 To lMaxRow Step 1
For lCol = 1 To lMaxCol Step 1
oTable.Rows(lRow).Cells(lCol).Shape.TextFrame.TextRange.Text = oWS.Cells(lRow, lCol)
Next lCol
Next lRow
Set oTable = Nothing
Set oSlide = Nothing
oPPT.Save
oPPT.Close
Set oPPT = Nothing
oPPTApp.Quit
Set oPPTApp = Nothing
End Sub
Friday, July 10, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment