none
copy certain range of data from EXCEl and paste on certain slide in PPT using C#.net RRS feed

  • Question

  • I need to modify a cretain range of data from an excel  and paste on a slide in presentation using C# in .net 4. I am able to do this when I set the Presentation aplication  visible as true, but when I make it false to make the work in background, it throws error saying there is no active window.


    Some of the code part I have is:

    Microsoft.Office.Interop.PowerPoint.Application oPowerPointApplication = new Microsoft.Office.Interop.PowerPoint.Application();
    oPowerPointApplication.Visible = MsoTriState.msoTrue; //to show the presentation changing Live. Put false to make the work in back ground.



    then copy paste like these:

    rangedCells = sheet.get_Range(usedRange, Missing.Value);
    rangedCells.Copy();

    objSlide.Application.Activate();
    objSlide.Select();
    objSlide.Design.Application.ActiveWindow.View.Paste();


    When I make it work in background saying
    oPowerPointApplication.Visible = MsoTriState.msoFalse;
    It gives me error at "objSlide.Design.Application.ActiveWindow" saying there is no active window
    . Please, help me.....



    Monday, August 29, 2011 2:19 PM

Answers

  • I hope this helps

    I think this link is useful Link

    http://msdn.microsoft.com/ko-kr/office/bb839515

     

     

        private void Sheet1_Startup(object sender, System.EventArgs e)
        {
          this.Range["a1", "a10"].Copy(missing);
    
          Power.Application ppt= new Microsoft.Office.Interop.PowerPoint.Application();
          ppt.Visible = Microsoft.Office.Core.MsoTriState.msoTrue;
          Power.Presentation pre = ppt.Presentations.Add(Microsoft.Office.Core.MsoTriState.msoTriStateMixed);
          Power.Slide slide = pre.Slides.AddSlide(1, pre.SlideMaster.CustomLayouts[Power.PpSlideLayout.ppLayoutTitle]);
          ppt.Activate();
          ppt.ActiveWindow.View.Paste();
         }


    http://vsto.tistory.com
    • Marked as answer by Bruce Song Wednesday, September 7, 2011 7:57 AM
    Tuesday, August 30, 2011 12:12 AM