Click here to Skip to main content
15,905,148 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Automating a specific running instance of Powerpoint using C# in Win XP.

Kindly do the needful help.
Below code working fimne when run debug line by line .but without debug it is not working
TmrPPTAppClsMon.Stop();
bool blnTmrStts = TmrPPTAppClsMon.Enabled;
//pptApp = null;

pptApp = null;

Thread.Sleep(1000);


try
{

//It means that the object is already assigned a value
if (iPPTPrcID != -1) { return; }

Process[] prcArrPPT = Process.GetProcessesByName("POWERPNT");
//Wait till the PPT Application initiates
while (Process.GetProcessesByName("POWERPNT").Length != 1) { Thread.Sleep(500); }

Object obj = null;

obj = System.Runtime.InteropServices.Marshal.GetActiveObject("PowerPoint.Application");


pptApp = (PowerPoint.Application)obj;


GetWindowThreadProcessId(pptApp.HWND, out iPPTPrcID);
pptApp.PresentationOpen += new Microsoft.Office.Interop.PowerPoint.
EApplication_PresentationOpenEventHandler(Presentation_Open);

pptApp.SlideSelectionChanged += new Microsoft.Office.Interop.PowerPoint.
EApplication_SlideSelectionChangedEventHandler(SlideSelection_Changed);

pptApp.PresentationClose += new Microsoft.Office.Interop.PowerPoint.
EApplication_PresentationCloseEventHandler(Presentation_Close);

pptApp.PresentationSave += new Microsoft.Office.Interop.PowerPoint.
EApplication_PresentationSaveEventHandler(Presentation_Open);

foreach (PowerPoint.Presentation PrstnItm in pptApp.Presentations)
{
while (Process.GetProcessesByName("POWERPNT").Length != 1) { Thread.Sleep(500); }
Presentation_Open(PrstnItm);
}






}
Posted
Updated 16-Apr-10 0:44am
v3

1 solution

try the following link:
http://support.microsoft.com/kb/316126[^]

read the "Additional Notes" section.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900