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.