简体   繁体   English

将Word应用程序带到前面

[英]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. 我以编程方式创建Word文档,并询问用户是否要立即显示文档。

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. 我发现激活Doc和App都带来了前面的话,至少它对我有用。

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

If you remove the Minimize and Maximize and use wordApp.Show() does that help resolve your issue? 如果你删除最小化和最大化并使用wordApp.Show()有助于解决您的问题? Every time I display a new application I use .Show not .Activate . 每次我显示我用一个新的应用.Show.Activate Hope that helps. 希望有所帮助。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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