OzGrid

How to maximize IE window in VBA

< Back to Search results

 Category: [Excel]  Demo Available 

How to maximize IE window in VBA

 

The posted code opens a site normal size.

Code:
Option Explicit
Sub Campus_map()
Dim Msg As String, Ans As Variant
     
    Msg = "Would you like to open the Lebanon VA Campus Map?"
     
    Ans = MsgBox(Msg, vbYesNo, "Vocational Services Reminder")
     
    Select Case Ans
         
    Case vbYes
    'Message informs user that the process is running.
    MsgBox "Please wait, while I connect to the Lebanon VA Campus Map.", vbInformation, "Voc. Rehab - Referals"
Dim ie As Object
    Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
    ie.NAVIGATE "https://v2.interactive.medmaps.com/site/lebanonva"
     ie.Visible = True
     
    End Select
End Sub

 

 The user found this very helpful & easy to follow video. Here is the link:

https://www.ozgrid.com/forum/forum/h...-window-in-vba


Users can adapt my code to their own use. There are 2 parts to the code. 1) this piece of code is placed at the beginning General Declaration (module).

Code:
Option Explicit
Declare Function apiIEsize Lib "user32" Alias "ShowWindow" (ByVal hwnd As Long, ByVal cmdshow As Long) As Long
Global Const sw_maximize = 3

2) The size of the IE window IE is a 1 line piece of code

Code:
apiIEsize ie.hwnd, 3

is this case 3 = Maximized.

The user posted the entire code to show where I placed that one line:

Code:
Sub Campus_map()
Dim Msg As String, Ans As Variant
     
    Msg = "Would you like to open the Lebanon VA Campus Map?"
     
    Ans = MsgBox(Msg, vbYesNo, "Vocational Services Reminder")
     
    Select Case Ans
         
    Case vbYes
    'Message informs user that the process is running.
    MsgBox "Please wait, while I connect to the Lebanon VA Campus Map.", vbInformation, "Voc. Rehab - Referals"
Dim ie As Object
    Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
    ie.NAVIGATE "https://v2.interactive.medmaps.com/site/lebanonva"
     ie.Visible = True
     apiIEsize ie.hwnd, 3
    End Select
End Sub

 

Obtained from the OzGrid Help Forum.

Solution provided by FrankM.

 

See also: Index to Excel VBA Code and Index to Excel Freebies and Lesson 1 - Excel Fundamentals and Index to how to… providing a range of solutions and Index to new resources and reference sheets

 

See also:

How to generate multiple line charts VBA
How to create VBA to copy specific column from one sheet to another
How to use VBA to returning 5 left digits and pasting to bottom of existing data set
How to download a file using VBA

 

Click here to visit our Free 24/7 Excel/VBA Help Forum where there are thousands of posts you can get information from, or you can join the Forum and post your own questions.


Gallery



stars (0 Reviews)