473,397 Members | 1,972 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,397 software developers and data experts.

Getting PID of new Word.ApplicationClass()

9
First of all, I am unsure as to where to post it, so please let me know (or move it) to where it should be.

I create an instance of word as follows
Expand|Select|Wrap|Line Numbers
  1. Word.ApplicationClass wd = new Word.ApplicationClass();
  2. wd.Caption = "My Word";
  3. int wordHandle =  FindWindow("Opusapp", wd.Caption);
  4.  
Questions:
1)
Word.ApplicationClass wd = new Word.ApplicationClass();
creates the winword.exe process,right?then...how can I get the Process Id of that word instance I have just created?thus I can kill it at a later stage by
Expand|Select|Wrap|Line Numbers
  1.                 Process[] wordProcesses = Process.GetProcessesByName("WINWORD");
  2.                 foreach (Process p in wordProcesses)
  3.                 {
  4.                     if (p.Id = myProcessId)
  5.                         p.Kill;
  6. }
  7.  
2) When I open word using my app, the caption appears as "My Word", however sometimes (haven't been able to reproduce it always) when I open word using the shortcut to microsoft word 2007, the word document also has the "My Word" caption...Other times, it shows the expected caption "Document1", etc...Why is this happening?Where could I get in-depth information about Word.ApplicationClass?

If anyone can bring some light to these issues...

Many thanks
Mar 10 '09 #1
1 7220
aryanbs
42
Why you want to kill it, you can Quit it normally
You can make sure its been closed after quit running following code:

Expand|Select|Wrap|Line Numbers
  1.  try
  2.             {
  3.                 //release same way like below if you have any other object from word
  4.                 System.Runtime.InteropServices.Marshal.ReleaseComObject(WordApp);
  5.                 GC.Collect();
  6.                 GC.WaitForPendingFinalizers();
  7.             }
  8.  
  9.             catch (Exception ex)
  10.             {
  11.                 WordApp = null;
  12.             }
More Info here
http://msdn.microsoft.com/en-us/libr...ss(VS.80).aspx

http://msdn.microsoft.com/en-us/libr...rs(VS.80).aspx
Mar 14 '09 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: MSNEWS | last post by:
Hi I'm using the word.applicationclass within my vb.net application to convert some word documents to text files. Is there anyway I can disable macros whilst loading the document, in Word I...
2
by: ksskumar2000 | last post by:
Hi, I have added following two reference under COM tab, Microsoft Office 11.0 Object Library Microsoft Word 11.0 Object Library The software I have used: Visual studio 1.14 Microsoft Office...
3
by: selen | last post by:
Hello I add Microsoft Word 10.0 Object Library from reference com. and I am writing my code to create an instance of a Word application.My code is Word.ApplicationClass oWordApp = new...
4
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
3
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
0
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
14
by: Alan T | last post by:
These are the codes I created a document: _WordApp = new Interop.Word.Application(); _WordApp.Visible = false; _WordDoc = new Document(); _Missing = System.Reflection.Missing.Value;
2
by: Alan T | last post by:
private Interop.Word.Application _wordApp; What is the differences betwenn _wordApp.Quit(...) and _wordApp.Application.Quit(...) ?
2
by: saketmayur | last post by:
Hi , I have write the following code to open word document on server using Microsoft.Office.Interop.Word; string DocPath = System.Configuration.ConfigurationManager.AppSettings; ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.