I have a requirement to initiate more than one instance of an
application using the filenames. (the example below will start two
instances of MS Word).
My problem is that I need to kill each instance individually, but this
does not appear possible using the Process object. When I run the
example below the process object "p" can be viewed using Quick Watch
however process object p2 is displayed as undefined, with the added
affect of not being able to kill instance p2.
-Code----------------------------------------------
ProcessStartInfo startInfo = new ProcessStartInfo("a.doc");
startInfo.WindowStyle = ProcessWindowStyle.Minimized;
Process p = Process.Start(startInfo);
......
ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc");
startInfo2.WindowStyle = ProcessWindowStyle.Minimized;
Process p2 = Process.Start(startInfo2);
....
p.Kill();
....
p2.Kill();
-End Code----------------------------------------------
Does anyone have an explanation for this?
Is there another way of doing it?
Regards
Gavin 6 2086
Is Word opening b.doc using the same process as the first? That would explain it.
--
Dave Sexton dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word).
My problem is that I need to kill each instance individually, but this does not appear possible using the Process object. When I run the example below the process object "p" can be viewed using Quick Watch however process object p2 is displayed as undefined, with the added affect of not being able to kill instance p2.
-Code---------------------------------------------- ProcessStartInfo startInfo = new ProcessStartInfo("a.doc"); startInfo.WindowStyle = ProcessWindowStyle.Minimized; Process p = Process.Start(startInfo); ..... ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc"); startInfo2.WindowStyle = ProcessWindowStyle.Minimized; Process p2 = Process.Start(startInfo2); ... p.Kill(); ... p2.Kill(); -End Code----------------------------------------------
Does anyone have an explanation for this? Is there another way of doing it?
Regards Gavin
Thanks for your response Dave. I tested it using a text document
opening it in notepad and it works as I would have hoped, so you
appear to be correct in that it is opening Word in the same process.
That explains the problem a little further, however my problem still
remains...I need to be able to kill off one of the word documents
without killing off the other. Any ideas?
Thanks
Gavin
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>... Is Word opening b.doc using the same process as the first? That would explain it.
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om...I have a requirement to initiate more than one instance of an application using the filenames. (the example below will start two instances of MS Word).
My problem is that I need to kill each instance individually, but this does not appear possible using the Process object. When I run the example below the process object "p" can be viewed using Quick Watch however process object p2 is displayed as undefined, with the added affect of not being able to kill instance p2.
-Code---------------------------------------------- ProcessStartInfo startInfo = new ProcessStartInfo("a.doc"); startInfo.WindowStyle = ProcessWindowStyle.Minimized; Process p = Process.Start(startInfo); ..... ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc"); startInfo2.WindowStyle = ProcessWindowStyle.Minimized; Process p2 = Process.Start(startInfo2); ... p.Kill(); ... p2.Kill(); -End Code----------------------------------------------
Does anyone have an explanation for this? Is there another way of doing it?
Regards Gavin
Yep :)
Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there
(just search MSDN or groups.google.com) about automating Office applications.
You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET, hitting
the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time,
but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use COM
tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool to
wrap the assembly for you.
Here are examples of using automation in C#:
using Word;
...
Word.Application app =
Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;
This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too.
Here's another way of accessing Word (this way won't link Word to your process):
Word.Application app =
System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;
This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed, Word
is not.
If "app" = null then run the following line, and then run the above line once more (again testing for null!):
System.Diagnostics.Process.Start("Word");
GL
--
Dave Sexton dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... Thanks for your response Dave. I tested it using a text document opening it in notepad and it works as I would have hoped, so you appear to be correct in that it is opening Word in the same process.
That explains the problem a little further, however my problem still remains...I need to be able to kill off one of the word documents without killing off the other. Any ideas?
Thanks Gavin
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>... Is Word opening b.doc using the same process as the first? That would explain it.
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... >I have a requirement to initiate more than one instance of an > application using the filenames. (the example below will start two > instances of MS Word). > > My problem is that I need to kill each instance individually, but this > does not appear possible using the Process object. When I run the > example below the process object "p" can be viewed using Quick Watch > however process object p2 is displayed as undefined, with the added > affect of not being able to kill instance p2. > > -Code---------------------------------------------- > ProcessStartInfo startInfo = new ProcessStartInfo("a.doc"); > startInfo.WindowStyle = ProcessWindowStyle.Minimized; > Process p = Process.Start(startInfo); > ..... > ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc"); > startInfo2.WindowStyle = ProcessWindowStyle.Minimized; > Process p2 = Process.Start(startInfo2); > ... > p.Kill(); > ... > p2.Kill(); > -End Code---------------------------------------------- > > > Does anyone have an explanation for this? > Is there another way of doing it? > > Regards > Gavin
Thanks Dave...
I am familiar with the Word Object Library from VB6 days and wanted to
avoid it for a number of reasons....
1. The application we are developing will launch the windows default
application depending on the extension of file being opened, e.g. txt
files will launch notepad. In the case of .doc files it will open
Word, however we want this as flexible as possible so there may be a
situation where .doc files launch something other than Word.
2. Possible version conflicts, between version of word installed on
client machine and version of Microsoft Word Object Library that the
application has a dependency on.
It may be the case that we need to cater specifically for Word (and
Excel) due to the way it manages multiple documents within the one
process; this being the case the Word object library may be the way to
go, so I have managed to take your suggestion and build a prototype
and will bring it to the table as a squareish peg for the round hole.
Many thanks for your time and contribution. If you have any further
suggestions they would be much appreciated.
Regards
Gavin
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<Or**************@TK2MSFTNGP10.phx.gbl>... Yep :)
Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there (just search MSDN or groups.google.com) about automating Office applications.
You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET, hitting the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time, but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use COM tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool to wrap the assembly for you.
Here are examples of using automation in C#:
using Word; ... Word.Application app = Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;
This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too. Here's another way of accessing Word (this way won't link Word to your process):
Word.Application app = System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;
This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed, Word is not. If "app" = null then run the following line, and then run the above line once more (again testing for null!):
System.Diagnostics.Process.Start("Word");
GL
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... Thanks for your response Dave. I tested it using a text document opening it in notepad and it works as I would have hoped, so you appear to be correct in that it is opening Word in the same process.
That explains the problem a little further, however my problem still remains...I need to be able to kill off one of the word documents without killing off the other. Any ideas?
Thanks Gavin
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>... Is Word opening b.doc using the same process as the first? That would explain it.
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... >I have a requirement to initiate more than one instance of an > application using the filenames. (the example below will start two > instances of MS Word). > > My problem is that I need to kill each instance individually, but this > does not appear possible using the Process object. When I run the > example below the process object "p" can be viewed using Quick Watch > however process object p2 is displayed as undefined, with the added > affect of not being able to kill instance p2. > > -Code---------------------------------------------- > ProcessStartInfo startInfo = new ProcessStartInfo("a.doc"); > startInfo.WindowStyle = ProcessWindowStyle.Minimized; > Process p = Process.Start(startInfo); > ..... > ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc"); > startInfo2.WindowStyle = ProcessWindowStyle.Minimized; > Process p2 = Process.Start(startInfo2); > ... > p.Kill(); > ... > p2.Kill(); > -End Code---------------------------------------------- > > > Does anyone have an explanation for this? > Is there another way of doing it? > > Regards > Gavin
Thanks Dave...
I am familiar with the Word Object Library from VB6 days and wanted to
avoid it for a number of reasons....
1. The application we are developing will launch the windows default
application depending on the extension of file being opened, e.g. txt
files will launch notepad. In the case of .doc files it will open
Word, however we want this as flexible as possible so there may be a
situation where .doc files launch something other than Word.
2. Possible version conflicts, between version of word installed on
client machine and version of Microsoft Word Object Library that the
application has a dependency on.
It may be the case that we need to cater specifically for Word (and
Excel) due to the way it manages multiple documents within the one
process; this being the case the Word object library may be the way to
go, so I have managed to take your suggestion and build a prototype
and will bring it to the table as a squareish peg for the round hole.
Many thanks for your time and contribution. If you have any further
suggestions they would be much appreciated.
Regards
Gavin
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<Or**************@TK2MSFTNGP10.phx.gbl>... Yep :)
Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there (just search MSDN or groups.google.com) about automating Office applications.
You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET, hitting the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time, but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use COM tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool to wrap the assembly for you.
Here are examples of using automation in C#:
using Word; ... Word.Application app = Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;
This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too. Here's another way of accessing Word (this way won't link Word to your process):
Word.Application app = System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;
This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed, Word is not. If "app" = null then run the following line, and then run the above line once more (again testing for null!):
System.Diagnostics.Process.Start("Word");
GL
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... Thanks for your response Dave. I tested it using a text document opening it in notepad and it works as I would have hoped, so you appear to be correct in that it is opening Word in the same process.
That explains the problem a little further, however my problem still remains...I need to be able to kill off one of the word documents without killing off the other. Any ideas?
Thanks Gavin
"Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>... Is Word opening b.doc using the same process as the first? That would explain it.
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... >I have a requirement to initiate more than one instance of an > application using the filenames. (the example below will start two > instances of MS Word). > > My problem is that I need to kill each instance individually, but this > does not appear possible using the Process object. When I run the > example below the process object "p" can be viewed using Quick Watch > however process object p2 is displayed as undefined, with the added > affect of not being able to kill instance p2. > > -Code---------------------------------------------- > ProcessStartInfo startInfo = new ProcessStartInfo("a.doc"); > startInfo.WindowStyle = ProcessWindowStyle.Minimized; > Process p = Process.Start(startInfo); > ..... > ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc"); > startInfo2.WindowStyle = ProcessWindowStyle.Minimized; > Process p2 = Process.Start(startInfo2); > ... > p.Kill(); > ... > p2.Kill(); > -End Code---------------------------------------------- > > > Does anyone have an explanation for this? > Is there another way of doing it? > > Regards > Gavin
> It may be the case that we need to cater specifically for Word (and Excel) due to the way it manages multiple documents within the one process
Unfortunately, I believe you will have to cater to those apps. If your using the extension mapping, you're program will have to be
aware of MDI apps (as you've mentioned above).
I'm glad I could help.
--
Dave Sexton dave@www..jwaonline..com
-----------------------------------------------------------------------
<gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... Thanks Dave...
I am familiar with the Word Object Library from VB6 days and wanted to avoid it for a number of reasons....
1. The application we are developing will launch the windows default application depending on the extension of file being opened, e.g. txt files will launch notepad. In the case of .doc files it will open Word, however we want this as flexible as possible so there may be a situation where .doc files launch something other than Word. 2. Possible version conflicts, between version of word installed on client machine and version of Microsoft Word Object Library that the application has a dependency on.
It may be the case that we need to cater specifically for Word (and Excel) due to the way it manages multiple documents within the one process; this being the case the Word object library may be the way to go, so I have managed to take your suggestion and build a prototype and will bring it to the table as a squareish peg for the round hole.
Many thanks for your time and contribution. If you have any further suggestions they would be much appreciated.
Regards Gavin "Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<Or**************@TK2MSFTNGP10.phx.gbl>... Yep :)
Using Word automation you can access the opened documents and do what you will with them. There are plenty resources out there (just search MSDN or groups.google.com) about automating Office applications.
You need to reference an Interop wrapped Word assembly. You can do this by opening the project references dialog in VS.NET, hitting the COM tab and browsing for Microsoft Word. I don't believe Office supplies any Primary Interop assembly for Word at this time, but if I'm wrong it would be under the .NET tab, or in a folder somewhere in the office heirarchy of folders. For now, just use COM tab and select Word as I suggested. If it's not in the list, simply browse to the executable and add it. VS.NET will use a tool to wrap the assembly for you.
Here are examples of using automation in C#:
using Word; ... Word.Application app = Activator.CreateInstance(Type.GetTypeFromProgID("W ord.Application", false)) as Word.Application;
This code places the instance of Word in the ROT (running object table). Now, when you close your app, Word is closed too. Here's another way of accessing Word (this way won't link Word to your process):
Word.Application app = System.Runtime.InteropServices.Marshal.GetActiveOb ject("Word.Application") as Word.Application;
This code retrieves an instance of Word from the ROT, but does not "link" it to the running process. When your app is closed, Word is not. If "app" = null then run the following line, and then run the above line once more (again testing for null!):
System.Diagnostics.Process.Start("Word");
GL
-- Dave Sexton dave@www..jwaonline..com ----------------------------------------------------------------------- <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... > Thanks for your response Dave. I tested it using a text document > opening it in notepad and it works as I would have hoped, so you > appear to be correct in that it is opening Word in the same process. > > That explains the problem a little further, however my problem still > remains...I need to be able to kill off one of the word documents > without killing off the other. Any ideas? > > Thanks > Gavin > > "Dave" <NO*********@dotcomdatasolutions.com> wrote in message news:<OE**************@TK2MSFTNGP12.phx.gbl>... >> Is Word opening b.doc using the same process as the first? That would explain it. >> >> -- >> Dave Sexton >> dave@www..jwaonline..com >> ----------------------------------------------------------------------- >> <gi***@consultant.com> wrote in message news:de**************************@posting.google.c om... >> >I have a requirement to initiate more than one instance of an >> > application using the filenames. (the example below will start two >> > instances of MS Word). >> > >> > My problem is that I need to kill each instance individually, but this >> > does not appear possible using the Process object. When I run the >> > example below the process object "p" can be viewed using Quick Watch >> > however process object p2 is displayed as undefined, with the added >> > affect of not being able to kill instance p2. >> > >> > -Code---------------------------------------------- >> > ProcessStartInfo startInfo = new ProcessStartInfo("a.doc"); >> > startInfo.WindowStyle = ProcessWindowStyle.Minimized; >> > Process p = Process.Start(startInfo); >> > ..... >> > ProcessStartInfo startInfo2 = new ProcessStartInfo("b.doc"); >> > startInfo2.WindowStyle = ProcessWindowStyle.Minimized; >> > Process p2 = Process.Start(startInfo2); >> > ... >> > p.Kill(); >> > ... >> > p2.Kill(); >> > -End Code---------------------------------------------- >> > >> > >> > Does anyone have an explanation for this? >> > Is there another way of doing it? >> > >> > Regards >> > Gavin This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: imani_technology_spam |
last post by:
We need to present hierarchical data on a web page, the same way the
tree view shows files in Windows Explorer. Here's the catch: that
tree view needs to be bound to a SQL Server database. How...
|
by: Lorem Ipsum |
last post by:
interesting! I just found a page in which Explorer's View Source does
nothing! How did they do that?
|
by: jloxsom |
last post by:
Hi all...
New user new to VC++.
I've used the AppWizard to create an SDI with the CFormclass. The
"View" file is a dialog. I want to create a few EditBoxes, associate
member variables to...
|
by: dw |
last post by:
Hello, all. I have a site that works fine when viewed in IE apart from the
project in Visual Studio .NET 2003. However, when I right-click and do View
in Browser, it tries to open it in the wrong...
|
by: bnlockwood |
last post by:
I'm looking to have the same kind of feature gmail does in that it is
able to view pdf files as html. I want to be able to have a PDF file,
have a view as html button but not have 2 files one html...
|
by: Wildemar Wildenburger |
last post by:
Hi there :)
I don't know how else to call what I'm currently implementing: An object
that behaves like a list but doesn't store it's own items but rather
pulls them from a larger list (if they...
|
by: RSH |
last post by:
Hi,
I have a user created control that has quite a bit of codebehind code. I
have one link in the HTML page code that I need to insert the current URL
in. I have tried several scenerios but...
|
by: alessandro menchini |
last post by:
Hello,
First of all: i apologize for my english...i'm still learning...
If i create a view it seems that DB2 manage this view like an
updateable view.
But I need to create a view "read only",...
|
by: Phaiz |
last post by:
Not sure if you'd need an activex control but I'm looking for a script to change the folder view to "Classic View" within IE.
I have an iframe that loads the users My Documents folder and would...
|
by: Naresh1 |
last post by:
What is WebLogic Admin Training?
WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: Matthew3360 |
last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: Rahul1995seven |
last post by:
Introduction:
In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| |