Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How To Maximize IE Window via VBA 2

Status
Not open for further replies.

PBAPaul

Programmer
Aug 3, 2002
140
GB
I use the following function to open Internet Explorer via VBA from Excel.

Code:
Function GetWeb(URL As String) As String
   Dim IEApp As Object
   Set IEApp = CreateObject("InternetExplorer.Application")
   IEApp.Visible = True
   IEApp.Navigate URL
End Function

Sub Test
GetWeb "[URL unfurl="true"]www.MyPage.com"[/URL]
end sub

This works fine but I want to ensure that the IE window is maximized. I cannot seem to find a command to do this.

Any ideas please?

Paul
 
something like this ...

Code:
Option Explicit

Public Declare Function ShowWindow _
    Lib "user32" ( _
    ByVal hwnd As Long, _
    ByVal nCmdShow As Long) _
As Long

Public Declare Function SetForegroundWindow _
    Lib "user32" ( _
    ByVal hwnd As Long) _
As Long

Public Const SW_MAXIMIZE As Long = 3&        'Show window Maximised

Sub Tester()
Dim objIe As Object
Dim strFilePath As String

Set objIe = CreateObject("internetexplorer.application")
strFilePath = "[URL unfurl="true"]http://www.tek-tips.com/viewthread.cfm?qid=905088"[/URL]

    With objIe
        .Navigate strFilePath
        '// Set offline JIC user NOT Online
        .offline = True
        '// Maximise the Ie window if not Already Max
        .Visible = True
        '// This routine used to Maximise Ie
        ShowWindow objIe.hwnd, SW_MAXIMIZE
        SetForegroundWindow objIe.hwnd
    End With
    
End Sub


Ivan F Moala
xcelsmall.bmp
 
Ivan

You're a star! Have a star!

It works perfectly. Thanks.

Paul
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top