Hi
I try to convert ppt to video:;
i know that CreateVideo is part of presentation. but, when i try this i have this error:
Inline Code Example Here

Looks like createvideo is not part of presentation.

Microsoft.Office.Interop.PowerPoint.Application pptApplication = new Microsoft.Office.Interop.PowerPoint.Application();

            Microsoft.Office.Interop.PowerPoint.Slides slides;
            Microsoft.Office.Interop.PowerPoint._Slide slide;
            Microsoft.Office.Interop.PowerPoint.TextRange objText; 

            // Create the Presentation File
            Presentation pptPresentation = pptApplication.Presentations.Add(MsoTriState.msoTrue);

            Microsoft.Office.Interop.PowerPoint.CustomLayout customLayout = pptPresentation.SlideMaster.CustomLayouts[Microsoft.Office.Interop.PowerPoint.PpSlideLayout.ppLayoutText];

            // Create new Slide
            slides = pptPresentation.Slides;
            slide = slides.AddSlide(1, customLayout);

            Microsoft.Office.Interop.PowerPoint.Shape shape = slide.Shapes[1];

            string picturePath = Directory.GetCurrentDirectory()+ @"/Untitled.jpg";            
            slide.Shapes.AddPicture(picturePath, MsoTriState.msoTrue,
            MsoTriState.msoFalse, shape.Left, shape.Top, shape.Width, shape.Height);

            slide = slides.AddSlide(2, customLayout);
            slide.Shapes.AddPicture(picturePath, MsoTriState.msoTrue,
            MsoTriState.msoFalse, shape.Left, shape.Top, shape.Width, shape.Height);

            Microsoft.Office.Interop.PowerPoint.Presentation preVideo;
            preVideo.CreateVideo("movie.mwv");      //ERROR

What's the error message?

Error 2 Use of unassigned local variable 'preVideo'

Microsoft.Office.Interop.PowerPoint.Presentation preVideo; You declare the variable here but never assign an object to it.

Just use pptPresentation.CreateVideo("movie.wmv"); instead. Should work.

Thanks Ketsuekiame
I have an error with yours recommendation (I do try catch for debugging)

" system.runtime.interopservieces.COMExpeception (0x80004005):
Error HRESULT E_FAIL has be returened from call a COM Components
at Microsoft.Office.Interop.PowerPoin._Presentation.CreateVideo(string... "

Ok, it seems that we've both misunderstood what this method does. What you're actually asking it to do is put a video INTO your presentation. What you actually need to do is call SaveCopyAs with the type PpSaveAsFileType.PpSaveAsWMV

Be warned that this can be a long process. It might be wise to display a dialog to indicate that your program is doing something while this happens.

Ketsuekiame
thanks about yours support.
I simply miss the required path

it is solved

string movie = Directory.GetCurrentDirectory() + @"/movie.wmv";
pptPresentation.CreateVideo(movie);
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.