PowerPoint Events in .net

G

Guest

Hi, I am writing a .net application and need to hook up to PowerPoint events.
I have been through the KB article but I cannot get it to catch any
PowerPoint eventd (I am using ppt 2003 and have tried both c# and vb
versions).

my code is here:

public MainForm()
{
ppt = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
ppt.Visible=Microsoft.Office.Core.MsoTriState.msoTrue;

System.Runtime.InteropServices.ComTypes.IConnectionPoint mConnectionPoint;
System.Runtime.InteropServices.ComTypes.IConnectionPointContainer cpContainer;
int mCookie;

cpContainer =
(System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)ppt;
Guid guid = typeof( Microsoft.Office.Interop.PowerPoint.EApplication ).GUID;
cpContainer.FindConnectionPoint( ref guid, out mConnectionPoint );
mConnectionPoint.Advise( this, out mCookie );

}

[DispId(2006)]
public void
PresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
{
System.Windows.Forms.MessageBox.Show("!");
}

I would be grateful for any help.

Thanks,

Ashley
 
G

Guest

Hi Austin,

I have written a class to open powerpoint and hook up to the events. The
knowledge base articles for both vb and c# suggest using the approach I have
used below, and c# doesn't have a withevents keyword to my knowledge...can
you please clarify what you mean a little further.

Thanks,

Ashley

Austin Myers said:
ash,

With PPT you must build your own WithEvents class module.

Austin Myers
MS PowerPoint MVP Team

Provider of PFCPro, PFCMedia and PFCExpress
www.playsforcertain.com


ash said:
Hi, I am writing a .net application and need to hook up to PowerPoint
events.
I have been through the KB article but I cannot get it to catch any
PowerPoint eventd (I am using ppt 2003 and have tried both c# and vb
versions).

my code is here:

public MainForm()
{
ppt = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
ppt.Visible=Microsoft.Office.Core.MsoTriState.msoTrue;

System.Runtime.InteropServices.ComTypes.IConnectionPoint mConnectionPoint;
System.Runtime.InteropServices.ComTypes.IConnectionPointContainer
cpContainer;
int mCookie;

cpContainer =
(System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)ppt;
Guid guid = typeof(
Microsoft.Office.Interop.PowerPoint.EApplication ).GUID;
cpContainer.FindConnectionPoint( ref guid, out mConnectionPoint );
mConnectionPoint.Advise( this, out mCookie );

}

[DispId(2006)]
public void
PresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
{
System.Windows.Forms.MessageBox.Show("!");
}

I would be grateful for any help.

Thanks,

Ashley
 
A

Austin Myers

This is your lucky day! Fellow MVP Shyam Pillai has done all the leg work
for your. Go to: http://skp.mvps.org/vb/vbppt003.htm

Shyam not only explains it, he has all the code needed to fire PowerPoint
from an external application. Of course you will need to make minor changes
to do it in .NET.

Austin Myers
MS PowerPoint MVP Team

Provider of PFCPro, PFCMedia and PFCExpress
www.playsforcertain.com



ash said:
Hi Austin,

I have written a class to open powerpoint and hook up to the events. The
knowledge base articles for both vb and c# suggest using the approach I
have
used below, and c# doesn't have a withevents keyword to my knowledge...can
you please clarify what you mean a little further.

Thanks,

Ashley

Austin Myers said:
ash,

With PPT you must build your own WithEvents class module.

Austin Myers
MS PowerPoint MVP Team

Provider of PFCPro, PFCMedia and PFCExpress
www.playsforcertain.com


ash said:
Hi, I am writing a .net application and need to hook up to PowerPoint
events.
I have been through the KB article but I cannot get it to catch any
PowerPoint eventd (I am using ppt 2003 and have tried both c# and vb
versions).

my code is here:

public MainForm()
{
ppt = new Microsoft.Office.Interop.PowerPoint.ApplicationClass();
ppt.Visible=Microsoft.Office.Core.MsoTriState.msoTrue;

System.Runtime.InteropServices.ComTypes.IConnectionPoint
mConnectionPoint;
System.Runtime.InteropServices.ComTypes.IConnectionPointContainer
cpContainer;
int mCookie;

cpContainer =
(System.Runtime.InteropServices.ComTypes.IConnectionPointContainer)ppt;
Guid guid = typeof(
Microsoft.Office.Interop.PowerPoint.EApplication ).GUID;
cpContainer.FindConnectionPoint( ref guid, out mConnectionPoint );
mConnectionPoint.Advise( this, out mCookie );

}

[DispId(2006)]
public void
PresentationOpen(Microsoft.Office.Interop.PowerPoint.Presentation Pres)
{
System.Windows.Forms.MessageBox.Show("!");
}

I would be grateful for any help.

Thanks,

Ashley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top