I need to embed excel file as object in powerpoint using vba macros on active slide..
Can anyone help me.
I tried below code,but it was creating new ppt and adding file on given location.
But I need to browse and select the excel file in active slide
Code
- Sub WKSEmbedInPPT()
- Dim objAppPPT As Object 'PowerPoint.Application
- Dim objPPTPres As Object 'PowerPoint.Presentation
- Dim objPPTSlide As Object 'PowerPoint.Slide
- Dim objPPTShape As Object 'PowerPoint.Shape
- Dim wbk As Workbook
- Set objAppPPT = CreateObject("PowerPoint.Application")
- objAppPPT.Visible = 1 'msoCTrue
- Set objPPTPres = objAppPPT.Presentations.Add
- objAppPPT.ActiveWindow.ViewType = 1
- objAppPPT.ActiveWindow.View.GotoSlide Index:=objPPTPres.Slides.Add(Index:=objPPTPres.Slides.Count + 1, Layout:=12).SlideIndex
- Set objPPTShape = objPPTPres.Slides(1).Shapes.AddOLEObject(Left:=100, Top:=100, _
- Width:=200, Height:=300, _
- ClassName:="Excel.Sheet", DisplayAsIcon:=True) 'OR Use , Filename:="E:\Documents and Settings\User\My Documents\abc.xlsm" instead of ClassName but not both
- With objPPTShape
- 'Code Manipulations here if required on the Object
- End With
- Set objAppPPT = Nothing
- Set objPPTPres = Nothing
- Set objPPTShape = Nothing
- Set objPPTSlide = Nothing
- End Sub