Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
sachingodhania
Contributor III
Contributor III

Embed excel in ppt via QV macro

Hi All,

I am trying to embed Excel file in the PPT via QV macro but in vain. Below is the macro ,

Sub WKSEmbedInPPT()

Dim objAppPPT 'PowerPoint.Application
Dim objPPTPres 'PowerPoint.Presentation
Dim objPPTSlide 'PowerPoint.Slide
Dim objPPTShape 'PowerPoint.Shape

Dim wbk 

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(1, 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

Please let me know if some have done this sort of macro earlier.

Thanks,

Sachin

2 Replies
marcus_sommer

I think you should look within the vbs/vba/office foren to these topic and build a routine from excel which worked - if you didn't find enough useful postings, the macro-recorder could be very helpful - and then you could convert it into a vbs-routine.

- Marcus

Frank_Hartmann
Master II
Master II

I had the same problem! Try like below:

Sub InsertOLEobject 

    filepath = "C:\Users\Admin\Desktop\.........xls"

    'Insert OLEObjects (Excel app&Icon) into PP sheet 

    Set PPApp = CreateObject("Powerpoint.Application")

    PPApp.Presentations.Open "C:\Users\Admin\Desktop\.......pptx" 

    Set EL = PPApp.ActivePresentation.Slides("Slide328").Shapes.AddOLEObject(, , , , ,filepath, True, , ,"Title of Excel")

    'Change Position of OLEObject

     With EL

         .Top = 380

         .Left = 50

     End with

End sub

For finding out the slideno there are several macros available!

Hope this helps!