简体   繁体   中英

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. 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

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