Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To go along with Tim Williams. You can do it quite easily by using create object to get an IE object vs using a shell call. This makes it easier since you have access to the object, and don't need try to look up the window handle after the fact.</p> <pre><code>Global Const SW_MAXIMIZE = 3 Global Const SW_SHOWMINIMIZED = 2 Global Const SW_SHOWNORMAL = 1 Declare Function apiShowWindow Lib "user32" Alias "ShowWindow" _ (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long Public Function Test() Dim ie As Object 'reference "Microsoft Internet Controls (ieframe.dll)", and 'cast ie as "InternetExplorer" if you wish to use intellisense Set ie = CreateObject("InternetExplorer.Application") ie.Visible = True apiShowWindow ie.hwnd, SW_MAXIMIZE End Function </code></pre> <p>If you are dealing with multiple monitors or need more control over the window, then it gets a little more tricky. Here is one of my previous answers to address that: <a href="https://stackoverflow.com/questions/6739052/is-it-possible-to-launch-a-browser-window-in-vba-maximized-in-the-current-monito/6753011#6753011">Is it possible to launch a browser window in VBA maximized in the current monitor?</a></p> <p>EDIT. Set window to certain position:</p> <pre><code>Public Type RECT x1 As Long y1 As Long x2 As Long y2 As Long End Type Public Enum SetWindowPosFlags SWP_ASYNCWINDOWPOS = &amp;H4000 SWP_DEFERERASE = &amp;H2000 SWP_DRAWFRAME = &amp;H20 SWP_FRAMECHANGED = &amp;H20 SWP_HIDEWINDOW = &amp;H80 SWP_NOACTIVATE = &amp;H10 SWP_NOCOPYBITS = &amp;H100 SWP_NOMOVE = &amp;H2 SWP_NOOWNERZORDER = &amp;H200 SWP_NOREDRAW = &amp;H8 SWP_NOREPOSITION = SWP_NOOWNERZORDER SWP_NOSENDCHANGING = &amp;H400 SWP_NOSIZE = &amp;H1 SWP_NOZORDER = &amp;H4 SWP_SHOWWINDOW = &amp;H40 End Enum Public Enum SpecialWindowHandles HWND_TOP = 0 HWND_BOTTOM = 1 HWND_TOPMOST = -1 HWND_NOTOPMOST = -2 End Enum 'taken from IE's ReadyState MSDN Specs Enum READYSTATE READYSTATE_UNINITIALIZED = 0 READYSTATE_LOADING = 1 READYSTATE_LOADED = 2 READYSTATE_INTERACTIVE = 3 READYSTATE_COMPLETE = 4 End Enum Declare Function SetWindowPos Lib "user32.dll" (ByVal hWnd As Long, ByVal hWndInsertAfter As SpecialWindowHandles, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal uFlags As SetWindowPosFlags) As Boolean Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Sub RunIt() Dim ie As Object Dim r As RECT Set ie = CreateObject("InternetExplorer.Application") 'draws a 400 pixel x 400 pixel window in position 0 (top left) r.x1 = 0 r.y1 = 0 r.x2 = r.x1 + 400 r.y2 = r.y1 + 400 'HWND_TOP sets the Z Order to our IE Object 'x2 - x1 ==&gt; Width (In Pixels) 'y2 - y2 ==&gt; Height (In Pixels) SetWindowPos ie.hWnd, HWND_TOP, r.x1, r.y1, (r.x2 - r.x1), (r.y2 - r.y1), SWP_ASYNCWINDOWPOS ie.Visible = True ie.Navigate "www.google.com" 'wait until navigated Do While ie.Busy Or ie.READYSTATE &lt;&gt; READYSTATE.READYSTATE_COMPLETE Sleep 60 Loop End Sub </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload