vba 如何使 Microsoft Word 应用程序出现在实例化它的 Microsoft Access 之上?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8203023/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How do I make a Microsoft Word application appear on top of the Microsoft Access for which instantiated it?
提问by GeneQ
I have a Microsoft Access form which will display a Microsoft Word app with a blank document when a particular button is clicked using the following code :
我有一个 Microsoft Access 表单,当使用以下代码单击特定按钮时,它将显示一个带有空白文档的 Microsoft Word 应用程序:
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add ' create a new document
All is fine except I can never get the Word window to appear on top of the Access window. It just appears in the task bar.
一切都很好,只是我永远无法让 Word 窗口出现在 Access 窗口的顶部。它只是出现在任务栏中。
Basically, I want to use Microsoft Word as a pop-up rich text editor.
基本上,我想使用 Microsoft Word 作为弹出式富文本编辑器。
How can I position the newly opened Microsoft Word app on top of the Microsoft Access form which instantiated it?
如何将新打开的 Microsoft Word 应用程序放置在实例化它的 Microsoft Access 表单之上?
回答by GeneQ
After much trail and error, I've found the solution:
经过多次跟踪和错误,我找到了解决方案:
If Tasks.Exists("Microsoft Word") Then
AppActivate "Microsoft Word"
End If
回答by Michiel van der Blonk
GeneQ's own answer didn't work for me. What did work was
GeneQ 自己的回答对我不起作用。什么工作是
Set w = New Word.Application
w.Visible = True
w.Activate
w.WindowState = wdWindowStateMaximize