PowerPoint 2007 controls for embedded Excel workbook?

D

Dan

With PowerPoint 2003 I could control a linked Excel file with a
control in PowerPoint. For example, I could create a spinner control,
link it to a cell in a linked Excel file, and use that to change the
numbers on a graph in that linked file.

When I ran a slideshow in PowerPoint, clicking on the spinner would
change the value in Excel, and the linked graph would update
automatically, creating the appearance that Excel didn't even exist
(though it had to be open.)

At the end of this post is the macro used to do this, from an answer
on ExpertsExchange.

So, my question is -- how can I do this in PowerPoint 2007, when the
Excel object is embedded in the PPT file (and therefore there is no
external file to reference). Is there a reference-able name for the
embedded Excel objects in PPT? Or is there a better way to do this
altogether?

Thanks
Dan


Private Sub SpinButton1_Change()
Dim xlApp As Object, wb As Object, ws As Object, shp As Shape

On Error Resume Next
Set xlApp = GetObject(, "Excel.Application")
On Error GoTo 0

If xlApp Is Nothing Then
Set xlApp = CreateObject("Excel.Application")
End If

On Error Resume Next
Set wb = xlApp.Workbooks("xlChart.xls")
On Error GoTo 0

If wb Is Nothing Then Set wb = xlApp.Workbooks.Open("C:\xlChart.xls")

xlApp.Visible = False

Set ws = wb.Worksheets("Sheet1")

ws.[D6] = SpinButton1.Value

ws.Calculate

For Each shp In Me.Shapes
If shp.Type = msoLinkedOLEObject Then
shp.LinkFormat.Update
End If
Next shp

End Sub
 
D

Dan

I think I figured this one out. Had to add references to Excel 12.0
object model.

Then I used the following:

Private Sub SpinButton1_Change()
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet

Set xlApp = GetObject(, "Excel.Application")
Set xlSheet = xlApp.ActiveWorkbook.ActiveSheet

xlApp.Visible = False

xlSheet.Range("G4").Value = SpinButton1.Value

For Each shp In Me.Shapes
If shp.Type = msoLinkedOLEObject Then
shp.LinkFormat.Update
End If
Next shp
End Sub

Let me know if you can think of a better solution / improvements, etc.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top