Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / December 2006

Tip: Looking for answers? Try searching our database.

How to close WEB pages ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
javiernews - 06 Dec 2006 20:55 GMT
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 !
Douglas J. Steele - 06 Dec 2006 22:22 GMT
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.

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Hi,
>
[quoted text clipped - 5 lines]
>
> Thank you !
javiernews - 06 Dec 2006 23:18 GMT
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 ??
Alex Dybenko - 07 Dec 2006 11:13 GMT
Hi,
here one more sample:
http://www.mvps.org/access/api/api0025.htm

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Thank Douglas !
>
[quoted text clipped - 5 lines]
>
> Which API to use to close Internet Exporer Window ??
mcescher - 07 Dec 2006 13:31 GMT
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.

> Hi,
> From Access I can easily open a WEB page with:
[quoted text clipped - 4 lines]
> Message posted via AccessMonster.com
> http://www.accessmonster.com/Uwe/Forums.aspx/access-modules/200612/1
javiernews - 07 Dec 2006 16:57 GMT
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)
Dave Miller - 07 Dec 2006 21:46 GMT
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
javiernews - 08 Dec 2006 15:13 GMT
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)
Dave Miller - 08 Dec 2006 16:49 GMT
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:
> Thank You Dave !!
>
[quoted text clipped - 32 lines]
>
> (test in  Windows 2000 + Access 2003)
javiernews - 08 Dec 2006 17:53 GMT
Thank you Dave !

Now is working perfect !!!

Javier
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.