Deva Subbu

Deva Subbu

  • NA
  • 40
  • 28.7k

How to avoid opening the worddocument which is already open./Using C# .net

Apr 18 2011 5:43 AM

Hi Friends,

In my scenario am opening the WordDocument programatically,suppose if i'am opening the same worddocument i should prompt the message that the document is already opened ..

 Process[] pro = Process.GetProcessesByName("WINWORD"); 
           
if (pro.Length > 0) 
           
{ 
               
foreach (Process p in pro) 
               
{ 
                   p
.kill();  
               
} 
           
} 

i'am using the above code to find the process and killing already opened documents, the problem is its killing the wordexe so that all the other opened documents also destroyed.. so how to find the name of the document and close particular documents only..

i used "P.MainWindowTitle" to get the opened document name but its not showing all the opened documents rather showing the first opened document name.

Please suggest me the solution ..

thanks in advance

Dev..


Answers (5)