Discussion:
How to programmatically bring a Word window to front?
(too old to reply)
Andrew
2008-03-28 14:39:01 UTC
Permalink
Raw Message
Hello, friends,

In c#.net 2005, we have the following source, hoping to bring a Word window
to front. However, it does not work.

Any ideas? How to bring a Word window to front?

Thanks a lot.

------------------- source code

foreach (Microsoft.Office.Interop.Word.Document doc in this.wordApp.Documents)
{
if (String.Compare(doc.Path + "\\" + doc.Name, fullPathFileName, true)
== 0)
{
doc.Activate();
return;
}
}
Roßert G. Schaffrath
2008-03-29 15:02:13 UTC
Permalink
Raw Message
I don't believe you can bring the document to the foreground with
doc.Activate() call, only make it the active document. You should call
this.wordApp.Activate() after doc.Activate() to bring the Word window to
the foreground.

Robert

Andrew wrote:
> Hello, friends,
>
> In c#.net 2005, we have the following source, hoping to bring a Word window
> to front. However, it does not work.
>
> Any ideas? How to bring a Word window to front?
>
> Thanks a lot.
>
> ------------------- source code
>
> foreach (Microsoft.Office.Interop.Word.Document doc in this.wordApp.Documents)
> {
> if (String.Compare(doc.Path + "\\" + doc.Name, fullPathFileName, true)
> == 0)
> {
> doc.Activate();
> return;
> }
> }
>
>
Rahul Nandani
2010-10-12 18:14:44 UTC
Permalink
Raw Message
String.Compare method which u described is not working correctly plz suggest me some alternative to activate already open word document

> On Friday, March 28, 2008 10:39 AM Andre wrote:

> Hello, friends,
>
> In c#.net 2005, we have the following source, hoping to bring a Word window
> to front. However, it does not work.
>
> Any ideas? How to bring a Word window to front?
>
> Thanks a lot.
>
> ------------------- source code
>
> foreach (Microsoft.Office.Interop.Word.Document doc in this.wordApp.Documents)
> {
> if (String.Compare(doc.Path + "\\" + doc.Name, fullPathFileName, true)
> == 0)
> {
> doc.Activate();
> return;
> }
> }


>> On Saturday, March 29, 2008 11:02 AM rschaffrat wrote:

>> I don't believe you can bring the document to the foreground with
>> doc.Activate() call, only make it the active document. You should call
>> this.wordApp.Activate() after doc.Activate() to bring the Word window to
>> the foreground.
>>
>> Robert
>>
>> Andrew wrote:


>> Submitted via EggHeadCafe - Software Developer Portal of Choice
>> Lucene.Net Indexing Searching Entry Level Tutorial
>> http://www.eggheadcafe.com/tutorials/aspnet/c69ef65f-e3c6-409e-ab97-168897c74f83/lucenenet-indexing-searching-entry-level-tutorial.aspx
Loading...