简体   繁体   中英

Copying Powerpoint(2007) Slide in C#

I am using VS 2005 for Powerpoint Automation .What I am trying to do here is open existing PPT from specified location and write data to it.In some slides I have table structure,these tables are filled from Dataset in code.However the problem here is if the table in PPT have lets say 10 rows and Dataset has 20 or 30 which is more than 10 rows Now for this if there are 30 rows in Dataset then i exactly need 3 similar slides.How shall I duplicate the table structure in PPT using C# prior to filling the PPT Table . Till now what i have used is this

                   double SlideCount=0;
                    if (DS.Tables[0].Rows.Count > 10)
                    {
                        SlideCount = (DS.Tables[0].Rows.Count) / 10;

                        SlideCount = Math.Round(double.Parse(SlideCount.ToString()));

                        for (int i = 0; i < SlideCount; i++)
                        {
                            //Code to Duplicate slide
                        }
                      }

my ultimate goal is to eliminate blank Slides

I do this kind of thing in VBA, and since you haven't shown the code you'll use to access the presentation, it's hard to translate, but in general outline:

Open the presentation and get a reference to it (let's call it oPres)

Assuming that you want to duplicate the first slide, call this as many times as you need:

oPres.Slides(1).Duplicate

In your case, I doubt it'll matter, but as an FYI, the duplicate of Slide 1 will always appear directly after Slide 1, not at the end of the presentation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM