PC Review


Reply
Thread Tools Rate Thread

Check if Page is Opened

 
 
=?Utf-8?B?Unlhbg==?=
Guest
Posts: n/a
 
      15th May 2006
Hi. I am just starting out with VBA in Access. I am trying to have Access
open a web page. I can do that, but I also want to make sure the web page
has loaded within, say, 20 seconds.

I've been thinking of something like:

using AppActivate with the title of the page that it displays when it has
loaded and then repeating this action if there is an error (ie, no such
title, bc the page hasn't loaded) and if a counter has not been exceeded.

I'm not really sure how to put that together though. Any ideas??

Thanks,
Ryan
 
Reply With Quote
 
 
 
 
Douglas J. Steele
Guest
Posts: n/a
 
      15th May 2006
What exactly do you mean by having "Access open a web page"? Are you
strictly trying to open an instance of Internet Explorer and have the page
appear there, or do you have an instance of the Microsoft Web Browser
ActiveX control on a form in Access? If the latter, there's a
DownloadComplete event that you should be able to tap into.

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


"Ryan" <(E-Mail Removed)> wrote in message
news:17E8CDFA-69CF-4B39-A349-(E-Mail Removed)...
> Hi. I am just starting out with VBA in Access. I am trying to have
> Access
> open a web page. I can do that, but I also want to make sure the web page
> has loaded within, say, 20 seconds.
>
> I've been thinking of something like:
>
> using AppActivate with the title of the page that it displays when it has
> loaded and then repeating this action if there is an error (ie, no such
> title, bc the page hasn't loaded) and if a counter has not been exceeded.
>
> I'm not really sure how to put that together though. Any ideas??
>
> Thanks,
> Ryan



 
Reply With Quote
 
=?Utf-8?B?Unlhbg==?=
Guest
Posts: n/a
 
      16th May 2006
Hi Doug,

Thanks for the input. I am not doing anything too involved and I am not
using ActiveX (that's way over my head).

What I am trying to do is eliminate duplicate entry of data.

The data that gets entered into Access (via a form) also needs to be entered
into a third party web form. After the user has input a new record, I would
like them to be able to 'click a button' and have all that data entered into
the web form automatically. I have it working right now, but I am sure the
coding is not optimal.

The steps are:
1) Open web page.
2) Login.
3) Navigate to appropriate page.
4) Transfer data from access form fields to web form fields.

The thing that makes it easy (or doable at all with my limited skills) is
the fact that the web site can be navigated solely through keyboard commands.
So I am pretty much accomplishing everything through SendKeys.

I do not have a great way of knowing if and when the webpage has loaded,
though. My code works, but I am wondering if anyone could throw a few
pointers or tips my way. Here is the code (please do not laugh):


Private Sub EnterWebData_Click() 'Code behind button

Dim Login_Count
Login_Count = 0

Call OpenGump

Do 'Loop to check if page has loaded
Call PageCheck

If PageCheck = False Then
Call Wait(2)
Else: Exit Do
End If

Login_Count = Login_Count + 1
Loop Until Login_Count = 10

If PageCheck = False Then
MsgBox "Could not connect"
Exit Sub
End If

Call LoginGump

End Sub


Function OpenGump() 'open web page
On Error GoTo OpenGump_Err

FollowHyperlink "-web address here-"

OpenGump_Exit:
Exit Function

OpenGump_Err:
MsgBox Error$
Resume OpenGump_Exit

End Function


Function PageCheck() As Boolean 'test to see if page has loaded
On Error GoTo ErrHandle
PageCheck = True
AppActivate "user details" 'try to move focus to login page
Exit Function

ErrHandle: 'if could not move focus, page not loaded (yet)
PageCheck = False
Exit Function

End Function


Function Wait(z As Integer) 'pause
Dim x, y As Integer
x = 1
y = 1
Do
Do
x = x + 1
Loop Until x = 9000

x = 1
y = y + 1

Loop Until y = (z * 1000)
End Function

Function LoginGump() 'log in to site (send userid and pswd)

SendKeys "-userid-", 1
Call Wait(1)
SendKeys "{TAB}", 1
Call Wait(1)
SendKeys "-password-", 1
SendKeys "{Enter}", 1



Thanks,
Ryan

 
Reply With Quote
 
Douglas J Steele
Guest
Posts: n/a
 
      16th May 2006
SendKeys is notoriously problematic: it's too easy to change what's got
focus so that it doesn't do what you intend it to. I'd suggest not using it.

However, if the 3rd party doesn't offer a more reliable approach, I'm afraid
I can't offer you any alternative.

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


"Ryan" <(E-Mail Removed)> wrote in message
news:AE3DD540-424D-49FA-A186-(E-Mail Removed)...
> Hi Doug,
>
> Thanks for the input. I am not doing anything too involved and I am not
> using ActiveX (that's way over my head).
>
> What I am trying to do is eliminate duplicate entry of data.
>
> The data that gets entered into Access (via a form) also needs to be

entered
> into a third party web form. After the user has input a new record, I

would
> like them to be able to 'click a button' and have all that data entered

into
> the web form automatically. I have it working right now, but I am sure

the
> coding is not optimal.
>
> The steps are:
> 1) Open web page.
> 2) Login.
> 3) Navigate to appropriate page.
> 4) Transfer data from access form fields to web form fields.
>
> The thing that makes it easy (or doable at all with my limited skills) is
> the fact that the web site can be navigated solely through keyboard

commands.
> So I am pretty much accomplishing everything through SendKeys.
>
> I do not have a great way of knowing if and when the webpage has loaded,
> though. My code works, but I am wondering if anyone could throw a few
> pointers or tips my way. Here is the code (please do not laugh):
>
>
> Private Sub EnterWebData_Click() 'Code behind button
>
> Dim Login_Count
> Login_Count = 0
>
> Call OpenGump
>
> Do 'Loop to check if page has loaded
> Call PageCheck
>
> If PageCheck = False Then
> Call Wait(2)
> Else: Exit Do
> End If
>
> Login_Count = Login_Count + 1
> Loop Until Login_Count = 10
>
> If PageCheck = False Then
> MsgBox "Could not connect"
> Exit Sub
> End If
>
> Call LoginGump
>
> End Sub
>
>
> Function OpenGump() 'open web page
> On Error GoTo OpenGump_Err
>
> FollowHyperlink "-web address here-"
>
> OpenGump_Exit:
> Exit Function
>
> OpenGump_Err:
> MsgBox Error$
> Resume OpenGump_Exit
>
> End Function
>
>
> Function PageCheck() As Boolean 'test to see if page has loaded
> On Error GoTo ErrHandle
> PageCheck = True
> AppActivate "user details" 'try to move focus to login page
> Exit Function
>
> ErrHandle: 'if could not move focus, page not loaded (yet)
> PageCheck = False
> Exit Function
>
> End Function
>
>
> Function Wait(z As Integer) 'pause
> Dim x, y As Integer
> x = 1
> y = 1
> Do
> Do
> x = x + 1
> Loop Until x = 9000
>
> x = 1
> y = y + 1
>
> Loop Until y = (z * 1000)
> End Function
>
> Function LoginGump() 'log in to site (send userid and pswd)
>
> SendKeys "-userid-", 1
> Call Wait(1)
> SendKeys "{TAB}", 1
> Call Wait(1)
> SendKeys "-password-", 1
> SendKeys "{Enter}", 1
>
>
>
> Thanks,
> Ryan
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Check if a file has been opened Wayne-I-M Microsoft Frontpage 1 21st Oct 2008 01:18 PM
Page load of the parent page called twice when a modal dialog is opened from a button click of the user control on the parent page Samy Microsoft ASP .NET 2 15th Aug 2005 04:30 PM
How to check whether a given Document is opened or not? =?Utf-8?B?QmFzYXZhcmFq?= Microsoft Word Document Management 1 17th May 2005 09:43 PM
! How Do I Check Form is Opened ! Wembly Microsoft Access Forms 4 12th Sep 2003 03:45 AM
! How Do I Check Form is Opened ! TC Microsoft Access Form Coding 4 11th Sep 2003 02:56 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:31 AM.