Export PowerPoint with C#?

Hi,

Currently i am working on small application where i export all the slides in the powerpoint and display then in slide show using C# form.My Problem is that when my application runs on a system on which office is installed it works fine but it is giving me error when i am running on a system where office is not installed.

I know two methods of exporting the power point one is using export option and other is using screen capture method.

Please told me the solution to my problem that how i run my application on a system without office being installed on it.And i am com





Answer this question

Export PowerPoint with C#?

  • incendy

    Hi,

    I have tried your method also but it is not working.If u have sample for this method please let me know.


  • Luis Esteban Valencia Muñoz

    Hi,

    The code below works for me. As you can see, I commented the PowerPoint Viewer (pptview.exe) command line switches in so I would have a reference. This works fine. The only thing I do not like is that the viewer ends with the standard PowerPoint black screen with the smal text "End of slide show, click to exit." displayed. I'd rather the process terminate and release.

    The PowerPoint Viewer allows presentations without Office and it can be 'installed' either by downloading the viewer or packaging directly from PowerPoint. The code below is an application that executes the presentation via a C# application on a USB drive. The viewer is stored on the USB drive of course. Hope this helps.

     

    //Execute PowerPoint Viewer

    Process view = new Process();

    view.EnableRaisingEvents = true;

    view.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

    //Used in development for EXE called from debug folder.

    view.StartInfo.FileName = @"E:\bin\viewers\powerpoint\pptview.exe";

    //Command line switches for PowerPoint Viewer 2003:

    // /L -- Read a playlist of files contained within a text file (see below). Example: \pptview.exe /L "Playlist.txt"

    // /S -- Start without splash screen.

    // /P -- Print the presentation. Example: \pptview.exe /P "Presentation.ppt"

    // /D -- Prompt the Open dialog box to appear when slide show ends.

    // /N# -- Open presentation at a specified slide number "#". Example: /pptview.exe /n5 "presentation.ppt" would open at slide 5.

    //The playlist file is simply a list of presentation filenames (preceded by path as needed). PowerPoint plays these files

    //in the order given in the file. You can't use command line switches within the playlist.

    view.StartInfo.Arguments = @"/s /n1 E:\docs\ppt\cp.ppt";

    //Live code used when executed from USB. Commented out during development. This code is tested.

               //view.StartInfo.FileName = appPath + @"\bin\viewers\powerpoint\pptview.exe";

              //view.StartInfo.Arguments = @"/s /d " + appPath + @"docs\ppt\cp.ppt";

    view.Start();

    view.WaitForExit();


  • Josh Hawley

    Heya dude.

    The thing is, if you reference assemblies from other applictaions and software, you need to make sure that the dll's you referenced are located in the same directory of the target machine where you wish to run your app.

    --> What you should do is go to the output directory of your solution and get the office dll's that was refenced (the files will automatically be copied there on build) in your project. Copy them and put them in a directory which will be the same as the target machine. Remove the references to these dll's in your solution and reference them again - but in the new location you put them. When you run the app on the target machine make sure that those dll files are in the referenced directory on that machine.

    The other thing to remember is that some of these office dll's use COM, so you might need to register these dll's on the target machinhe using 'regsvr32 ~filename~' from a command prompt. You could use a batch file to do this for you or you could do this in code, the first time the app is run using:

    System.Diagnostics.Process.Start('regsvr32 ~filename~').



  • BrianMcCulloch

    Hi;
    Try installing PowerPoint viewer if you do not have office on the system. You can download it form this link
    http://www.microsoft.com/downloads/details.aspx FamilyID=428d5727-43ab-4f24-90b7-a94784af71a4&displaylang=en
    This should do the trick.
    Shivam

  • nbit

    Hi,

    I have tried the method as described by u but still i need power point to be installed on the machine.
    One more thing i like to know is that how i can make my application to be compatible with different version of the powerpoint.

    Gagandeep


  • Luis Esteban Valencia Muñoz

    Sorry Gagandep, Since you are using the Office Interops to access specific Office functionality, your code will only work on systems that have Office installed.


  • redshock

    Yo dude, i dunno.

    Once I created a plugin for an enterprise app and it exported data to Excel from a datagrid. I used the method I explained and it worked for me.

    Sorry I couldn't be of more assistance to you. Suppose you'll have to install office.



  • Export PowerPoint with C#?