in powerpoint 2007 ,I want to insert the mp4 file using C++ automation.
-
Friday, February 17, 2012 12:55 PM
In Powerpoint 2007 , i want to embed MP4 on Slide using C++ powertpoint automation.
by using msppt.tlb + wizard we have generated the wrapper .h files for powerpoint automation.as we cannot direclty embed MP4 in PPT 2007 , i create a OLE Object of ShockwaveFlash.ShockwaveFlash and set the movie property of that shape to the path of MP4 file.
I am able to create the olebject by using pShapes.AddOLEObject(0,0,VideoWidth,VideoHeight,L"ShockwaveFlash.ShockwaveFlash.7",L"",0,L"",0,L"",0);
But now i am not sure how to set the movie property on this.
in VB6 we used to do like shape.oleformat.object.movie ="path"
but here in C++ if i try to get the object from ole format i get the IDispatch *.Now i dont know how to set the movie property on this IDispatch.
Thanks in advance...
All Replies
-
Monday, February 20, 2012 9:27 AMModerator
Hi,
You shouldn't use add media as OLE object, using Shape.AddMediaObject2 method instead. Have a look at my code:
Sub addMovie() Dim fileName As String fileName = "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv" Dim sld As Slide Dim shp As Shape Set sld = Application.ActivePresentation.Slides(2) 'add media from file and with posiztion and size specified Set shp = sld.Shapes.AddMediaObject2(fileName, MsoTriState.msoFalse, MsoTriState.msoTrue, 0, 0, 300, 300) With shp.MediaFormat 'set volume and trim the video .Volume = 0.5 .StartPoint = 10000 .EndPoint = 20000 End With End SubThe VBA code work file on my side. You can try to translate to C++.
I hope this helps.
Calvin Gao[MSFT]
MSDN Community Support | Feedback to us
-
Wednesday, February 22, 2012 2:23 AM
Hello Calvin,
Thanks for your reply.
But my Scenario is :- i have to insert ".MP4" file in Powerpoint 2007.
in Powertpoint 2010 i have used the method explained by you But in
Powerpoint 2007 i dont think we can use Addmediaobject2. so to get the same effect i use OLEObject way. as flash activex can play MP4 so if we can set the "movie path" that will be ok for my scenario.
Thanks in advance.....
-
Tuesday, February 28, 2012 3:09 AM
Hello Calvin,
Thanks for your reply.
But my Scenario is :- i have to insert ".MP4" file in Powerpoint 2007.
in Powertpoint 2010 i have used the method explained by you But in
Powerpoint 2007 i dont think we can use Addmediaobject2. so to get the same effect i use OLEObject way. as flash activex can play MP4 so if we can set the "movie path" that will be ok for my scenario.
Thanks in advance.....
-
Wednesday, February 29, 2012 9:34 AMModerator
Hi,
For Powerpoint 2007, you can call Shapes.AddMediaObject Method, but if you prefer to store the media as OLEObject, you can call Shapes.AddOLEObject Method (PowerPoint)
But you should be aware of that you can either specify the ClassName or FileName argument, but you can't specify them both.
So if the object is added by ClassName specified, you can't set its path either. The code you should use would something like:
Sub AddMovieAsOLE() Dim file As String file = "C:\Users\Public\Videos\Sample Videos\Wildlife.wmv" Dim sld As Slide Dim shp As Shape Set sld = Application.ActivePresentation.Slides(2) Set shp = sld.Shapes.AddOLEObject(Left:=10, Top:=10, Width:=50, Height:=50, fileName:=file, DisplayAsIcon:=msoFalse, Link:=msoFalse) End SubI hope this helps.
Calvin Gao[MSFT]
MSDN Community Support | Feedback to us
- Marked As Answer by Calvin_GaoModerator Thursday, March 08, 2012 9:53 AM

