IE won't re-maximise - pasting this code in will work

M

Mike NG

Hi
I am reposting this as I still had some code missing and the point about
the reference

Pasting this in will now compile

Calling GotoURL first time round works fine
Try minimising your browser window
Call GotoURL a second time

It does not re-maximise itself. I'm sure it did when I wrote this under
XL97. Now on XL2000 it doesn't work

Insert Module
paste the following code in
set a reference to Microsoft Internet Controls

Option Explicit
Public Declare Function ShowWindow Lib "user32" (ByVal hWnd As _
Long, ByVal nCmdShow As Long) As Long

Public Declare Function IsIconic Lib "user32" (ByVal hWnd As Long) _
As Long
Const SW_SHOW = 9
Const SW_RESTORE = 8
Const SW_MAXIMIZE = 3

Dim oIE As InternetExplorer
'**************************
'* Start IE and visit URL *
'**************************
Sub GotoURL(psURL As String)

Dim bPresent As Boolean
Dim sTypeName As String


'GetObject ("",InternetExplorer.Application) will latch on to
'Turnpike is less functional than full IE
'GetObject ("",InternetExplorer) won't latch on to IE at all
'(known feature), so implement our own kind of version which
'does the same sort of thing
sTypeName = TypeName(oIE)

If sTypeName = "Nothing" Or sTypeName = "Object" Then
'Nothing means never initialised
'Object means a previous IE instance has been shut down
Set oIE = New InternetExplorer
Else
'Instance already running
bPresent = True
End If


'All this seems to be necessary too, because it seems to be
'the only way to bring iconised windows back to life because
'there is no WindowState attribute
With oIE
If bPresent Then
If IsIconic(.hWnd) Then
ShowWindow .hWnd, SW_RESTORE
Else
ShowWindow .hWnd, SW_SHOW
ShowWindow .hWnd, SW_MAXIMIZE
End If
Else
ShowWindow .hWnd, SW_MAXIMIZE
End If

.Navigate psURL
End With

End Sub
 
M

Mike

Maybe this will work for you
You can use .TheaterMode = True 'full screen


Sub LoadWebPage()
Dim oleIE As Object
Set oleIE = CreateObject("InternetExplorer.Application")
With oleIE
.TheaterMode = True 'full screen
.Visible = True
.Navigate "http://www.rondebruin.nl/Google.htm"
End With
End Sub
That's fine, but the challenge is when page comes up,
1) minimise it to the task bar
2) call LoadWebPage again

And I need the same instance of IE to come up again. This is because I
have to sign in only once if I do it like this
 
R

Ron de Bruin

Hi Mike

You can use this to open it always in the same window

Option Explicit

Private Declare Function GetDesktopWindow Lib "user32" () As Long

Private Declare Function ShellExecute Lib "shell32.dll" _
Alias "ShellExecuteA" _
(ByVal hwnd As Long, ByVal lpOperation As String, _
ByVal lpFile As String, ByVal lpParameters As String, _
ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long

Public Sub RunShellExecute(ByVal sFile As Variant)
Dim hWndDesk As Long
Dim success As Long
Const SE_ERR_NOASSOC = &H31
hWndDesk = GetDesktopWindow()
success = ShellExecute(hWndDesk, "Open", sFile, 0&, 0&, 3)
End Sub

Sub Run1()
RunShellExecute "http://groups.google.com/advanced_group_search?q=group:microsoft.public.excel.programming"
End Sub

Sub Run2()
RunShellExecute "http://groups.google.com/advanced_group_search?q=group:microsoft.public.excel.misc"
End Sub

Sub Run3()
RunShellExecute "http://groups.google.com/advanced_group_search?q=group:*Excel*"
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top