Calling macro in a linked Excel spreadsheet

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

A slide in my PPT 2003 contains a linked Excel 2003 file. The Excel file contains a macro that refreshes a web query. I want to create a macro in my PPT that will execute the Excel macro, but I can't figure out how to properly reference the Excel spreadsheet. I appreciate any help!

I've boiled my code down to:

Sub testmacro()

Dim oShape As Shape

' Get a reference to the shape linked spreadsheet
Set oShape = ActiveWindow.Selection.SlideRange.Shapes("Object 6")

' Execute the macro to refresh the spreadsheet data
oShape.LinkFormat.Application.Run ("RefreshData")

End Sub

The "Run" statement causes Runtime Error -2147188160 (80048240) Application (unknown member) : Invalid Request. Sub or function not defined.
 
Keith,
Try the following:
' Execute the macro to refresh the spreadsheet data
' oShape.LinkFormat.Application.Run ("RefreshData")

Dim oWB As Object
Set oWB = oShape.OLEFormat.Object
oWB.Application.Run "RefreshData"
oWB.Save
oShape.OLEFormat.Activate
oWB.Application.Quit
Set oExcel = Nothing

Regards
Shyam Pillai
 
Back
Top