Automatically open Excel 2007 from PowerPoint 2007?

D

Dan

Hi,

I am using the following code to manipulate an embedded Excel 2007
worksheet.

Problem is, the macro fails unless Excel 2007 is already open. How
can I force Excel 2007 to be open automatically?

Thanks
Dan


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

current = xlSheet.Range("G4").Value
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
 
A

Andy Pope

Hi,

I would guess this would fail in any excel version as creating the
application does not automatically open a workbook. So
ActiveWorkbook.Activesheet will fail.

After you get the object reference you need to check is a workbook is
open but more likely you need to open or add the workbook you want to
deal with.

Cheers
Andy
 
D

Dan

Thanks Andy. Do you know what the internal reference would be for an
embedded Excel 2007 worksheet in a PowerPoint 2007 slide?

Withh 2003 you had to refer to a specific Excel file outside of the
PowerPoint application. But with PowerPoint 2007 the Excel file is
embedded, which is what I want (to avoid sending two files to people)
but I don't know how to add the workbook once I get the object
reference.

Thanks,
Dan
 
A

Andy Pope

Hi,

I don't know that you can reference the embedded excel object. I believe the
Object Model is incomplete.

Cheers
Andy
 

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