简体   繁体   中英

Bring Word Application to Front

I programmatically create a Word document and ask the user if he want's to display the document right now.

In order to bring the document to front I minimize and maximize the document. The document comes to front of screen but in an 'impolite' way: you can see it gets minimized and maximized.

Any idea how to 'educate' it?

wordApp.Visible = true;//objApp is the word application defined in my application
//minimizing and maximizing bring the Word application to front
wordApp.WindowState=WdWindowState.wdWindowStateMinimize;
wordApp.WindowState=WdWindowState.wdWindowStateMaximize;
wordApp.Activate();

I found that activating both the Doc and the App brought word to the front, at least it did for me.

oDoc.Activate();
oWordApp.Activate();

If you remove the Minimize and Maximize and use wordApp.Show() does that help resolve your issue? Every time I display a new application I use .Show not .Activate . Hope that helps.

如果上述方法不起作用,您可以按照此处的建议使用Win32 API SetForegroundWindow函数。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM