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!
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.