BarneyMKM


I thought this would be easy to do, but it's proven to be difficult. I have an excel spreadsheet that I want to open from a Powerpoint macro. I've tried multiple variations of Workbooks.Open("....") , but get an Object Required error. Anyone know what I've done wrong

Barney




Re: Opening a .xls from a .ppt macro

bi-lya


You need to add the reference to Excel (if you use the early binding): Tools -> References..., and declare Excel like here

Code Snippet

Sub OpenExcel()
Dim eApp As Excel.Application
Dim eWb As Excel.Workbook

Set eApp = CreateObject("Excel.Application")
Set eWb = eApp.Workbooks.Open("c:\myfile.xls")
eApp.Visible = True
''''''''''''''''''''
''''''''''''''''''''
eApp.Quit
Set eApp = Nothing
Set eWb = Nothing
End Sub

If you use late binding, you may not add the reference, but you need to declare Excel as Object