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

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
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,224,822
Messages
6,181,165
Members
453,021
Latest member
Justyna P

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