open and maximise an IE window using vba

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
683
Office Version
  1. 2016
Platform
  1. Windows
Hi,
I have the following code that opens an internet window from Excel using vba, however the IE window never opens up 'maximised' - how can I adapt my code to achieve this?

Code:
Dim IE As Object
    Set IE = CreateObject("internetexplorer.application")
    IE.Visible = True
    IE.navigate "http://www.google.com"
    
    Do While IE.Busy: DoEvents: Loop
    Do While IE.readyState <> 4: DoEvents: Loop
 
Hi,
Replaced my macro with your code above but still not working, am getting:
Compile Error: Only Comments may appear after End Sub, End Function or End Property with the 'Private Declare' line highlighted
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
this code worked for me... a blank IE winow opened maximized... i have 64 bit excel so it needs to use PtrSafe since 64 bit excel references 64 bit memory addresses and user32 uses 32 bit addresses

Code:
Private Declare PtrSafe Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdSHow As Long) As Long



Sub Hey()
    Dim IE As Object
    Set IE = CreateObject("internetexplorer.application")
    ShowWindow IE.hwnd, 3
End Sub
 
Last edited:
Upvote 0
Great, have sussed it - I wasn't inputting the top statement correctly - it now has a line underneath it and it works fine.
Thanks for your time on this, much appreciated :)
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,279
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top