Re: Navigate Internet Explorer using VBA (Article in Access FAQs section) (1 Viewer)

ykjain

New member
Local time
Today, 16:53
Joined
Sep 16, 2010
Messages
1
Re: Navigate Internet Explorer using VBA (Article in Access FAQs section)

Hi, Thanks for the great article. I like the easy way you explained the article.

I am trying to access my internal website throught VBA. I have written code to press the 'SignOut' button (please view the HTML code), but after that, the website popup a window to confirm the action. I am not able to determine the button for this, as this popup is controlled by java (please see the HTML sourcecode).

Can you please suggest what needs to be written in VBA to make confirmation on the popup (that is to press yes button).


My VBA code to control the website is -

Sub opemweb()

Dim weblink As String
Dim sec As Integer
Dim TNow, TWait As Date

TWait = Now()
TWait = DateAdd("s", 60, TWait)
Do Until TNow >= TWait
TNow = Now()
Loop

Dim ie As Object
Set ie = CreateObject("INTERNETEXPLORER.APPLICATION")
ie.NAVIGATE http://fileserver/evssigninsignout/EVSSignInSignOut.aspx
While ie.busy
DoEvents
Wend
ie.Visible = True
ie.Document.all("SignOutButton").Click

End Sub





----------------------------------------------------------------------
The HTML Script of the above webpage is -


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script language="javascript">
function confirmSignIn()
{
var date1;
date1=document.getElementById("HidFordate").value;
//alert(date1);

answer=confirm("Are you sure you want to sign-in for " + date1 )
if (answer==0)
{
return false;
}
else
{
return true;
}

}

function confirmSignOut()
{
var date1;
date1=document.getElementById("HidFordate").value;
answer=confirm("Are you sure you want to sign-out for " + date1)
if (answer==0)
{
return false;
}
else
{
return true;
}

}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="no-cache">
<title>Welcome to Sign In & Sign Out Tool</title>
<style type="text/css">
body {
margin-left: 0px;
margin-top: 5px;
margin-right: 0px;
margin-bottom: 0px;
background-color: #dae9e0;
}
</style>
<link href="Styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form name="form1" method="post" action="EVSSignInSignOut.aspx" id="form1">
<div>
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTk4Njc2NTg0NQ8WBB4HU2lnbk91dAUCTk8eBlNpZ25JbgUCTk8WAgIBD2QWCgIBD2QWBgIBDw8WAh4EVGV4dAUTWW9nZW5kcmEgS3VtYXIgSmFpbmRkAgMPDxYCHwIFDFNpZ24gT3V0IEZvcmRkAgUPDxYCHwIFHFRodXJzZGF5LCBTZXB0ZW1iZXIgMTYsIDIwMTBkZAIFDw8WAh4HVmlzaWJsZWdkFgQCAQ8PFgIeCEltYWdlVXJsBRVGbGFnX0ltYWdlcy9JbmRpYS5qcGdkZAIDDw8WAh8CBUhZb3VyIHNpZ24taW4gdGltZSBmb3IgU2VwIDE2LCAyMDEwIGlzIFNlcCAxNiwgMjAxMCAxMTo0NiBBTSAoTG9jYWwgVGltZSlkZAIJD2QWAgIBDw8WAh8EBRVGbGFnX0ltYWdlcy9JbmRpYS5qcGdkZAILDw8WBB8EBRZpbWFnZXMvc2lnbmluX2J0bjEuZ2lmHgdFbmFibGVkaGRkAhMPDxYCHwNoZGQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9fFgMFDFNpZ25JbkJ1dHRvbgUNU2lnbk91dEJ1dHRvbgUIY2xvc2VCdG4okb+Lk5fNMENw0r3kP12vqyGmzQ==" />
</div>
<div>
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWBQKd2IiGCgLK2dfnBgKBi4TPDAKRpPNdAtS9/bsOmomgebjOCTOzW7T+vFspGNbNGIA=" />
</div>
<table cellpadding="0" cellspacing="0" align="center">
<tr valign="middle">
<td valign="middle">
<table width="485" height="277" border="0" align="center" cellpadding="0" cellspacing="0"
background="images/mainscreen_bg.jpg">
<tr>
<td valign="top">
<table width="100%" height="37" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="50" align="right" valign="middle">
<a alt="EVSIntranet/Default.aspx" href="http://Fileserver" style="color: #ffffff;">
Intranet Home</a>    </td>
</tr>
</table>
<table width="100%" height="214" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="7%" height="89">
 </td>
<td width="67%" height="89">
<table width="100%" border="0" cellspacing="0" cellpadding="4">
<div id="EmpDet1">

<tr>
<td width="3%">
<img src="images/arrow.jpg" width="7" height="9" /></td>
<td width="37%" class="regular_bold">
Employee Name
</td>
<td width="60%" class="regular">
<span id="empname" class="regular">Yogendra Kumar Jain</span></td>
</tr>
<tr>
<td>
<img src="images/arrow.jpg" width="7" height="9" /></td>
<td class="regular_bold">
<span id="SignInSingOutTextLbl" class="regular_bold">Sign Out For</span></td>
<td class="regular">
<span id="signinfor" class="regular">Thursday, September 16, 2010</span></td>
</tr>

</div>
<div id="ErrorPanel">

<tr>
<td colspan="3" class="clsErrorText">
<div align="center">
<span id="ErrorLabel" class="clsErrorText"></span>
</div>
</td>
</tr>

</div>
<div id="SignInMessagePanel">

<tr>
<td colspan="3" class="regular">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td width="12%">
<img id="SignInMessageImage" src="Flag_Images/India.jpg" style="border-width:0px;" /></td>
<td width="88%">
<div>
<span id="SignInMessageLabel" class="regular">Your sign-in time for Sep 16, 2010 is Sep 16, 2010 11:46 AM (Local Time)</span>
</div>
</td>
</tr>
</table>
</td>
</tr>

</div>
</table>
</td>
<td colspan="2">
 </td>
</tr>
<tr>
<td width="7%">
 </td>
<td height="100">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="regular" align="justify">
<div id="note" style="width:100%;">

<strong>Note:</strong> If you want to get the sign-in/sign-out record modified then
please raise an IT request. Sign-in/Sign-out report would be sent to Finance department
by end of day today, after which records would get freezed. Sign-in/Sign-out tool
is linked with the attendance system and this may affect your salary for the month.

</div>

</td>
</tr>
</table>
</td>
<td width="3%">
 </td>
<td width="23%" valign="top">
<div align="center">
<img src="images/spacer.gif" width="100" height="16" /><br />
<input type="image" name="SignInButton" id="SignInButton" disabled="disabled" src="images/signin_btn1.gif" style="border-width:0px;" />
<br />
<img src="images/spacer.gif" width="100" height="10" /><br />
<input type="image" name="SignOutButton" id="SignOutButton" src="images/signout_bn.gif" onclick="return confirmSignOut();" style="border-width:0px;" /></div>
</td>
</tr>
<tr>
<td>
 </td>
<td height="30">
 </td>
<td>
 </td>
<td valign="bottom">
<img src="images/spacer.gif" width="80" height="20" />
<input type="image" name="closeBtn" id="closeBtn" src="images/close_btn.gif" onclick="javascript:window.close();" style="border-width:0px;" /></td>
</tr>
</table>
</td>
</tr>
</table>
<input type="hidden" name="HidFordate" id="HidFordate" value="September 16, 2010" />
</td>
</tr>
<tr>
<td height="10">
</td>
</tr>
<tr>
<td>
<a href="images/Idea Submission Template - Final.doc">

</a>
<img id="ImgShutDown" src="images/shutdown-message.jpg" style="border-width:0px;" />
<!--<img src="images/shutdown-message.jpg" />-->
</td>
</tr>
<tr>
<td>
<span id="lblrr"></span>
</td>
</tr>
</table>
</form>
</body>
</html>

------------------------------------------------------------------------
 
Last edited:

Users who are viewing this thread

Top Bottom