Supercharge your PowerPoint productivity with
|
PPTools |
Excel MVP Jon Peltier's site includes this very useful Using Excel with Other Office Applications section. Recommended reading! And here's a simple example of how you can retrieve data from an Excel worksheet embedded in a PPT slide. Be sure to select the Excel object before running the code. There's no error handling to protect you here.
Sub GetXLSWorksheetDataExample()
' This assumes you've set a reference to the MS Excel object library in the IDE
Dim oWorkbook As Excel.Workbook
Dim oWorksheet As Excel.Worksheet
Dim oSh As Shape
Dim LastCol As Long
Dim LastRow As Long
Dim x As Long
Dim y As Long
' This example assumes you've selected the excel object
' you want to work with
Set oSh = ActiveWindow.Selection.ShapeRange(1)
Set oWorkbook = oSh.OLEFormat.Object
' Use the first sheet in the work book
Set oWorksheet = oWorkbook.worksheets(1)
' Get the last row/col
With oWorksheet
.Activate
' Find the extents of the data in the sheet
LastRow = .Range("a65535").End(xlUp).Row
LastCol = .Range("iv1").End(xlToLeft).Column
' Display the data
For x = 1 To LastRow
For y = 1 To LastCol
Debug.Print "Row" & CStr(x) & ":Col" & CStr(y) & " " & .Cells(x, y)
Next
Next
End With
oWorkbook.Close (False)
Set oWorkbook = Nothing
Set oWorksheet = Nothing
End Sub
Español Deutsch Français Português Italiano Nederlands Greek Japanese Korean Chinese |
Supercharge your PPT Productivity with PPTools
|
content authoring & site maintenance by |
Automate Excel from PowerPoint. Automate PowerPoint from Excel. And so on.
http://www.pptfaq.com/FAQ00368.htm
Last update 09 September, 2006