Excel 加载项表单在表单关闭时将 Excel 发送到后台
我有一个可以弹出表单的 Excel 加载项。如果用户填写一些值并单击“应用”按钮,这些值将正确发送到基础工作表,并且弹出表单将关闭。但是,如果用户单击“取消”,则会弹出一个消息框,验证用户是否想要取消。单击“是”会导致弹出窗体关闭,但也会将 Excel 发送到先前活动的窗口后面 - 非常类似于按 Alt-Tab。这可不好啊!
有人对如何保持 Excel 领先地位有任何想法吗?
谢谢!
兰迪
I have an Excel Add-In that pops up a form. If the user fills in some values and clicks the "Apply" button, the values are correctly sent to the underlying worksheet and the pop-up form closes. If, however, the user clicks on "Cancel," a Messagebox pops-up verifying that the user wants to cancel. Clicking "Yes" causes the pop-up form to close, but also sends Excel behind the previously active window -- very much like pressing Alt-Tab. This is not good!
Does anybody have any notions about how to keep Excel on top?
Thanks!
Randy
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以将其放在消息框之后
ActiveWindow.ActivatePrevious
并测试
You could put this in right after the message box
ActiveWindow.ActivatePrevious
And test with
我寻找了 ActiveWindow/ActiveView 的各种变体,但找不到任何适用的内容。最后我绕过桑树丛想出了这个:
丑陋,但它有效。工厂是一个创建/返回 Excel 实例的小类。
我非常感谢您的意见。
兰迪
I looked for all sorts of variations on ActiveWindow/ActiveView but couldn't find anything applicable. Finally I went around the Mulberry bush to come up with this:
Ugly, but it works. The factory is a small class that creates/returns the Excel instance.
I very much appreciate the input.
Randy