Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / August 2007

Tip: Looking for answers? Try searching our database.

PowerPoint automation in Webbrowser Control

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sam_sam80@hotmail.com - 09 Aug 2007 15:42 GMT
Hi,

I did PowerPoint automation winthin Webbrowser Control. I can
open .ppt file and browse the slides.
My problem is when I have an other session of PPT open outside the
Webbrowser control I losse the control of my own file.  Sometimes
when powerpnt process is still in the memory (caused by error in
closing PowerPoint) but not PowerPont is visible, I have the same
problem.

Here, a source code I use to do this.

//opning PPT file
object messing = System.Reflection.Missing.Value;
string filepath = "....."
this.axWebBrowser1.Navigate(filepath, ref messing, ref messing, ref
messing, ref messing);

// Get the powerpoint object
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
  opDisp = e.pDisp;
  oDocument =
opDisp.GetType().InvokeMember("Document",BindingFlags.GetProperty,null,opDi­
sp,null);
  oApplication =
opDisp.GetType().InvokeMember("Application",BindingFlags.GetProperty,null,o­
Document,null);

  // I can't do automation from this object oApplication

  Object oPresentation =
opDisp.GetType().InvokeMember("ActivePresentation",BindingFlags.GetProperty­,
null, oApplication, null);
  Object oSlides =
opDisp.GetType().InvokeMember("Slides",BindingFlags.GetProperty, null,
oPresentation, null);
   int slideCount = (int)
(opDisp.GetType().InvokeMember("Count",BindingFlags.GetProperty,
null,
oSlides, null));
   Object oSlideShowWindow =
opDisp.GetType().InvokeMember("SlideShowWindow",BindingFlags.GetProperty,
null, oPresentation, null);
   Object oSSWView =
opDisp.GetType().InvokeMember("View",BindingFlags.GetProperty, null,
oSlideShowWindow, null);

  // PowerPoint Application object
  PowerPoint.Application pptApplication =
(PowerPoint.Application)oApplication;

   // Add Event handlers
  pptApplication.SlideShowNextBuild +=new
PowerPoint.EApplication_SlideShowNextBuildEventHandler(pptApplication_Slide­
ShowNextBuild);
  pptApplication.SlideShowNextSlide +=new
PowerPoint.EApplication_SlideShowNextSlideEventHandler(pptApplication_Slide­
ShowNextSlide);
  pptApplication.SlideShowNextClick +=new
PowerPoint.EApplication_SlideShowNextClickEventHandler(pptApplication_Slide­
ShowNextClick);
}

Any help is very appreciate
Samir
Nicholas Paldino [.NET/C# MVP] - 09 Aug 2007 16:03 GMT
What do you mean you lose control of your file?

Signature

         - Nicholas Paldino [.NET/C# MVP]
         - mvp@spam.guard.caspershouse.com

Hi,

I did PowerPoint automation winthin Webbrowser Control. I can
open .ppt file and browse the slides.
My problem is when I have an other session of PPT open outside the
Webbrowser control I losse the control of my own file.  Sometimes
when powerpnt process is still in the memory (caused by error in
closing PowerPoint) but not PowerPont is visible, I have the same
problem.

Here, a source code I use to do this.

//opning PPT file
object messing = System.Reflection.Missing.Value;
string filepath = "....."
this.axWebBrowser1.Navigate(filepath, ref messing, ref messing, ref
messing, ref messing);

// Get the powerpoint object
private void axWebBrowser1_DocumentComplete(object sender,
AxSHDocVw.DWebBrowserEvents2_DocumentCompleteEvent e)
{
  opDisp = e.pDisp;
  oDocument =
opDisp.GetType().InvokeMember("Document",BindingFlags.GetProperty,null,opDi­
sp,null);
  oApplication =
opDisp.GetType().InvokeMember("Application",BindingFlags.GetProperty,null,o­
Document,null);

  // I can't do automation from this object oApplication

  Object oPresentation =
opDisp.GetType().InvokeMember("ActivePresentation",BindingFlags.GetProperty­,
null, oApplication, null);
  Object oSlides =
opDisp.GetType().InvokeMember("Slides",BindingFlags.GetProperty, null,
oPresentation, null);
   int slideCount = (int)
(opDisp.GetType().InvokeMember("Count",BindingFlags.GetProperty,
null,
oSlides, null));
   Object oSlideShowWindow =
opDisp.GetType().InvokeMember("SlideShowWindow",BindingFlags.GetProperty,
null, oPresentation, null);
   Object oSSWView =
opDisp.GetType().InvokeMember("View",BindingFlags.GetProperty, null,
oSlideShowWindow, null);

  // PowerPoint Application object
  PowerPoint.Application pptApplication =
(PowerPoint.Application)oApplication;

   // Add Event handlers
  pptApplication.SlideShowNextBuild +=new
PowerPoint.EApplication_SlideShowNextBuildEventHandler(pptApplication_Slide­
ShowNextBuild);
  pptApplication.SlideShowNextSlide +=new
PowerPoint.EApplication_SlideShowNextSlideEventHandler(pptApplication_Slide­
ShowNextSlide);
  pptApplication.SlideShowNextClick +=new
PowerPoint.EApplication_SlideShowNextClickEventHandler(pptApplication_Slide­
ShowNextClick);
}

Any help is very appreciate
Samir

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.