How to close WEB pages ?

  • Thread starter Thread starter javiernews via AccessMonster.com
  • Start date Start date
J

javiernews via AccessMonster.com

Hi,

From Access I can easily open a WEB page with:

Application.FollowHyperlink (strUrl)

But,.......... How Can I close the WEB page from Access (with code) ??

Thank you !
 
Unfortunately, I don't think it's possible to give a generic answer to this.

FollowHyperlink will open the page in whatever browser is set as the
default. To close the browser, you'd need to find the appropriate open
window (and since you don't know what browser was used, it's non-trivial to
find which window is the correct one), and then close it.

http://www.mvps.org/access/api/api0013.htm at "The Access Web" shows you how
to loop through all open Windows.

Once you've got a handle to the correct window, you can use the SendMessage
API to simulate clicking on the Close button.
 
Thank Douglas !

"Once you've got a handle to the correct window, you can use the SendMessage
API to simulate clicking on the Close button."


I understand , but,........

Which API to use to close Internet Exporer Window ??
 
Would it be possible to embed a browser on a form and Navigate2 the
page you want to open. Then close the form when you want.

HTH,
Chris M.
 
Thank you Alex & Chris !



I'm using the following code but it Not working very well. Some times it
works some
other times doesn't the code is the following:




Private Sub Command17_Click()
On Error GoTo Error_local

Const strWindow As String = "IEFrame" ' <<
http://www.mvps.org/access/api/api0013.htm
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strUrl As String


Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("tblWebs", dbOpenDynaset)

rst.MoveLast
rst.MoveFirst

If rst.RecordCount = 0 Then
MsgBox "No data", vbExclamation
GoTo Close_Local:
End If


Debug.Print "************************************"



Do Until rst.EOF

strUrl = rst.Fields("Http")
strUrl = Replace(strUrl, "#", "")
DoEvents
Application.FollowHyperlink strUrl, , NewWindow:=True

If fCloseApp(strWindow) = True Then '<<
http://www.mvps.org/access/api/api0025.htm
' MsgBox "se ha cerrado la ventana", vbInformation
Else
MsgBox "No se ha cerrado la ventana", vbCritical
End If

rst.Edit
rst.Fields("UltimoAcceso") = Now '<< Last date opened WEB page
rst.Update

GoTo Next_Local

Error_local:
Debug.Print strUrl
If MsgBox("Quieres borrar el siguiente registro", vbYesNo +
vbQuestion + vbDefaultButton2) = vbYes Then
rst.Edit
rst.Delete
rst.Update
End If

Next_Local:
rst.MoveNext

Loop


Close_Local:
Set rst = Nothing
Set dbs = Nothing

End Sub
'******** end code ***********


I have a table with many webs PAGES and I want to check all of them.
Information in the table is like this: http://www.accessmonster.com


Why my code is Not running well ???
(I mean after same time it stops)
 
This is what I use to control internet explorer

David Miller
***********************************************************************
Dim ie As Object
Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = False
.Navigate sURL
Do Until ie.ReadyState = 4
DoEvents
Loop
sGetURLText = ie.Document.Body.innertext
If InStr(1, sGetURLText, "The page cannot be found",
vbTextCompare) Then sGetURLText = ""
ie.Quit
End With
Set ie = Nothing
 
Thank You Dave !!

I tryed your code like this,...... but nothing happen,.......

Private Sub Command21_Click()
Dim ie As Object
Dim sURL As String
Dim sGetURLText As String

sURL = "http://www.google.com/"


Set ie = CreateObject("InternetExplorer.Application")
With ie
.Visible = False
.Navigate sURL
Do Until ie.ReadyState = 4
DoEvents
Loop

sGetURLText = ie.Document.Body.innertext


If InStr(1, sGetURLText, "The page cannot be found", vbTextCompare)
Then
sGetURLText = ""
End If

ie.Quit
End With

Set ie = Nothing

End Sub


The code is Not working ,......... :-(((

(test in Windows 2000 + Access 2003)
 
The code is opening the web page then closing it without you seeing it.

- Change

..Visible = False

to

..Visible = True


-Change

ie.Quit

to

if msgbox("Close?", vbyesno)=vbyes then
.quit
end if





javiernews via AccessMonster.com wote:
 
Back
Top