是否可以在当前监视器中最大化的 VBA 中启动浏览器窗口?
我需要能够从 VBA 代码启动浏览器窗口(这部分很简单),但我还需要它在当前监视器上最大化显示。为了让事情变得更好(读作:更糟),我需要支持四显示器显示。因此,用户可以在 4 个独立的显示器上激活 4 个窗口,并且根据哪个窗口/显示器触发网站打开,网站应该在该显示器中最大化。
正如我之前提到的,启动一个网站是微不足道的(是的,IE 是必需的。嘘。):
Shell ("cmd /c start c:\progra~1\intern~1\iexplore.exe http://www.google.com")
但是,围绕此的几个细节很麻烦,即:
- 我可以指定吗新进程中显示的窗口在哪里启动?
- 我可以指定新进程中显示的窗口将最大化显示吗?
- 我可以使用 此 Win32 函数检测两个以上的显示器?
- 知道当前是哪台显示器后,我可以指定在哪台显示器上显示新窗口吗?
任何为我指明正确方向的建议都会很有帮助!
I need to be able to launch a browser window from VBA code (that part's easy), but I also need it to display maximized on the current monitor. To make things better (read: worse), I need to support a quad-monitor display. So, the user could have 4 windows active on 4 separate monitors, and depending on which window/monitor triggers the website to open, it should be maximized in that monitor.
As I mentioned before, launching a website is trivial (yes, IE is a requirement. Boo.):
Shell ("cmd /c start c:\progra~1\intern~1\iexplore.exe http://www.google.com")
However, several details surrounding this are troublesome, namely:
- Can I specify where the window shown in a new process starts up?
- Can I specify that a window shown in a new process will be shown maximized?
- Can I detect more than two monitors using this Win32 Function?
- Knowing which monitor is the current one, can I specify which monitor to show the new window on?
Any advice pointing me in the right direction would be helpful!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我以为这将从 Excel 中调用。这个想法是,您传递 Excel 对象窗口句柄 (hWnd) 并从 User32 检索其“矩形”对象。然后,您可以使用此矩形数据创建一个 IE 实例,并使用 SetWindowPos API 调用将 IE 对象覆盖在目标矩形之上。最后,我们使用 ShowWindowAsync API 命令发出 Maximize 命令,然后在网站中加载。我目前无法在双显示器上进行测试,但它应该给您一个良好的开始。
I assumed this is going to be called from Excel. The Idea is that you pass your Excel Objects window Handle (hWnd) and retrieve its 'Rectangle' Object from User32. Using this rectangle data, You then create an IE instance and overlay your IE object overtop of the target Rectangle using the SetWindowPos API call. Finally, we issue the Maximize command with the ShowWindowAsync API command, then load in the website. I currently cannot test on dual monitors, but it should give you a good start.