将 Excel SaveAs 对话框置于前面 Visual Basic(不是 VBA)
我编写了一个 Visual Basic 程序,它连接到 Access 数据库,生成一些 SQL 语句,然后尝试将结果写入 Excel 文件。
一切正常,除了调用“另存为”对话框时:
xlApp.Dialogs(Excel.XlBuiltInDialog.xlDialogSaveAs).Show()
该对话框位于程序后面,处于最大化状态。因此,程序在等待对话框关闭时似乎挂起,但无法访问该对话框(Alt+Tab 除外,但这是一个丑陋的解决方法)。
有什么办法让我将对话框强制放在前面吗?我在此处找到了相关主题< /a> 但我不处理单独的线程。那里的OP建议使用BringToFront方法,但我不确定如何在我的xlApp.Dialogs中使用它。
预先感谢您的帮助!
I've written a Visual Basic program that connects to an Access database, makes a few SQL statements, then tries to write it the results to an excel file.
Everything works properly, except when it calls the SaveAs dialog:
xlApp.Dialogs(Excel.XlBuiltInDialog.xlDialogSaveAs).Show()
The dialog is behind the program, which is maximized. Thus, the program appears to hang as it's waiting for the dialog to close, but the dialog cannot be accessed (except by Alt+Tab, but that's an ugly workaround).
Any way for me to force the Dialog to the front? I found a related thread here but I'm not dealing with separate threads. The OP there suggests the BringToFront method, but I'm not sure on how to use that with my xlApp.Dialogs.
Thanks in advance for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
找到窗口句柄并调用 SetForegroundWindow
因此,使用上面的函数,您应该能够执行以下操作:
不要忘记同时装饰 SetForegroundWindow:
Find the window handle and call SetForegroundWindow
So with the above function you should be able to do something like:
Don't forget to decalre SetForegroundWindow as well: