简体   繁体   English

如何在vb.NET中将Word应用程序置于最前面

[英]How to bring word application to the front in vb.NET

I am using winforms and when I try to open a word document programmatically it goes behind all the opened windows randomly. 我正在使用winforms,当我尝试以编程方式打开Word文档时,它随机出现在所有打开的窗口后面。 How can I bring it to the front? 我怎样才能把它带到前面? Following is my code. 以下是我的代码。

    Dim pAppWord As Object = CreateObject("Word.Application")

'//do my stuff '//做我的东西

    pAppWord.Visible = True
    pAppWord.Application.Activewindow = True
    '//pAppWord.Active() found this online but throws an error
    pAppWord.WindowState = vbNormal

Thanks!! 谢谢!!

对我有用的是

pAppWord.Activate()

这似乎并不简单...也许这会有所帮助: http ://social.msdn.microsoft.com/Forums/pl-PL/vblanguage/thread/fd9215cf-0893-4c61-886c-5d22fa7c2055

如果添加或打开了一个文档(例如wordOb.Documents.Add),则只需将wordOb.ActiveWindow.Hwnd传递给Windows API函数SetForegroundWindow

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

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