VBA .getElementbyID which has onchange event

Thilan

New Member
Joined
Jul 13, 2021
Messages
10
Office Version
  1. 2016
Platform
  1. Windows
I have the following code which automate data entry in web page.
but unable to complete the codes due to an error. below is given the current codes and website element where error occurs.

Codes:
Sub automateIE()

Dim IE As Object
Dim URL As String

Set IE = CreateObject("InternetExplorer.application")

IE.Visible = True
IE.navigate "IIS Windows Server"

Do While IE.Busy
Application.Wait DateAdd("S", 1, Now)
Loop
Set doc = IE.document
IE.document.getelementbyid("userid").Value = "xxxxx"
IE.document.getelementbyid("password64").Value = "xxxxxx"
IE.document.getelementbyid("company_code").Value = "xxxx"
IE.document.getelementbyid("branch_code").Value = "xxx"
IE.document.getelementbyid("login1").Click

Do While IE.Busy
Application.Wait DateAdd("S", 1, Now)
Loop

Set doc = IE.document
IE.document.getelementbyid("236").Click
IE.document.getelementbyid("4916").Click

Do While IE.Busy
Application.Wait DateAdd("S", 1, Now)
Loop

Set doc = IE.document
IE.document.getelementbyid("template_id").Value = "2631" - here is the error comes

End Sub

1648411415609.png



Here is the HTML from web site

1648411784927.png





kindly help me to short this out Thanks.
 

Attachments

  • 1648411409829.png
    1648411409829.png
    5.1 KB · Views: 27
  • 1648411568250.png
    1648411568250.png
    11.2 KB · Views: 25

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
The id is "employee_code", not "template_id". Therefore try:
VBA Code:
IE.document.getelementbyid("employee_code").Value = "2631"
 
Upvote 0
The id is "employee_code", not "template_id". Therefore try:
VBA Code:
IE.document.getelementbyid("employee_code").Value = "2631"
The id is "employee_code", not "template_id". Therefore try:
VBA Code:
IE.document.getelementbyid("employee_code").Value = "2631"
i change the id as mention above but error is still there
 
Upvote 0
I have no idea if this will work, and have no way of testing it, but looking at how it's been described in the onchange code, what if you tried:
VBA Code:
IE.Document.employee_form.employee_code.value = 2631
With or without quotation marks around 2631 - I'm not sure if that'll make a difference.
This assumes that the code on the page actually works. Though to be honest, if John_w's suggestion didn't work, I don't see that this should either.
 
Upvote 0
i change the id as mention above but error is still there
If you click Debug on the error and execute the line again does the error still occur? If so, that could mean the element isn't yet available, in which case you need to wait until it is available:
VBA Code:
    Dim ECelement As Object, timeout As Date
    timeout = DateAdd("s", 10, Now)
    Do
        Set ECelement = IE.document.GetElementById("employee_code")
        DoEvents
    Loop While ECelement Is Nothing And Now < timeout
    If Not ECelement Is Nothing Then
        ECelement.Value = "2631"
    Else
        Stop 'timeout occurred
    End If
Another possibility is that the element is in a frame/iframe, in which case you need to get the HTMLdocument in the frame.
 
Upvote 0
If you click Debug on the error and execute the line again does the error still occur? If so, that could mean the element isn't yet available, in which case you need to wait until it is available:
VBA Code:
    Dim ECelement As Object, timeout As Date
    timeout = DateAdd("s", 10, Now)
    Do
        Set ECelement = IE.document.GetElementById("employee_code")
        DoEvents
    Loop While ECelement Is Nothing And Now < timeout
    If Not ECelement Is Nothing Then
        ECelement.Value = "2631"
    Else
        Stop 'timeout occurred
    End If
Another possibility is that the element is in a frame/iframe, in which case you need to get the HTMLdocument in the frame.
Code modified as above but still error in below line

Set ECelement = IE.document.GetElementById("employee_code")

below is the web document for your checking. appreciate your help.

1648472500107.png
 
Upvote 0
You need to verify that the code is looking at the correct page (HTMLdocument). Put these lines after the IE.Busy wait loop:
VBA Code:
Range("A1").Value = IE.document.getElementsByTagName("HTML")(0).outerHTML
MsgBox "Number of iframes = " & IE.document.getElementsByTagName("iframe").Length
Stop
to put the page's HTML in cell A1 and display the number of iframes in the main HTMLdocument. Check that HTML to see if it contains the employee code input element. If not, it means the input element is in another HTMLdocument embedded in the main HTMLdocument, using an iframe tag.
 
Upvote 0
You need to verify that the code is looking at the correct page (HTMLdocument). Put these lines after the IE.Busy wait loop:
VBA Code:
Range("A1").Value = IE.document.getElementsByTagName("HTML")(0).outerHTML
MsgBox "Number of iframes = " & IE.document.getElementsByTagName("iframe").Length
Stop
to put the page's HTML in cell A1 and display the number of iframes in the main HTMLdocument. Check that HTML to see if it contains the employee code input element. If not, it means the input element is in another HTMLdocument embedded in the main HTMLdocument, using an iframe tag.
below is the Cell A1 HTML & number of iframes -2

<html dir="ltr"><head><script src="https://oss.menaitechsystems.com/IM...query/jquery-3.3.1.min.js?dontcash=3296964058" type="text/javascript"></script>


<style type="text/css">cufon{text-indent:0!important;}@media screen,projection{cufon{display:inline!important;display:inline-block!important;position:relative!important;vertical-align:middle!important;font-size:1px!important;line-height:1px!important;}cufon cufontext{display:-moz-inline-box!important;display:inline-block!important;width:0!important;height:0!important;overflow:hidden!important;text-indent:-10000in!important;}cufon canvas{position:relative!important;}}@media print{cufon{padding:0!important;}cufon canvas{display:none!important;}}</style></head><body class="body_BK" id="main_body" style="margin: 0px; overflow: hidden;"><form novalidate="novalidate">
<input name="system_language_input" id="system_language_input" type="hidden" value="1" autocomplete="off">
<input name="system_company_input" id="system_company_input" type="hidden" value="IMTIAZ" autocomplete="off">
<input name="system_branch_input" id="system_branch_input" type="hidden" value="HQ" autocomplete="off">
<input name="system_name_input" id="system_name_input" type="hidden" value="is_MenaPay" autocomplete="off">
<input name="is_system_name_ta" id="is_system_name_ta" type="hidden" value="" autocomplete="off">
<input name="is_system_freemium" id="is_system_freemium" type="hidden" value="0" autocomplete="off">
<input name="helpPageCat" id="helpPageCat" type="hidden" value="" autocomplete="off">
<input name="lite_input" id="lite_input" type="hidden" value="0" autocomplete="off">
<input name="system_name" id="system_name" type="hidden" value="menapay/" autocomplete="off">
<input name="HRMS_localDate" id="HRMS_localDate" type="hidden" value="28/03/2022" autocomplete="off">
<input name="setup_use_hijri_dates_admin" id="setup_use_hijri_dates_admin" type="hidden" value="0" autocomplete="off">
</form>
<form novalidate="novalidate" name"nosubmit"="">
<input name="site_host_path_input" id="site_host_path_input" type="hidden" value="Main Login" autocomplete="off">
</form>
<noscript>
&lt;meta http-equiv="refresh" content="0;url=:: MenaITech ::"/&gt;



</noscript>
<script src="https://oss.menaitechsystems.com/IM...napay/lib/form_actions.js?dontcash=4945446087" type="text/javascript"></script>
<script src="https://oss.menaitechsystems.com/IM.../menapay/lib/formcheck.js?dontcash=6593928116" type="text/javascript"></script>
<link href="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/skins/Light/Style_ltr.css?vars=11799" rel="stylesheet" type="text/css">
<link href="https://oss.menaitechsystems.com/IM...ared/css/freemiucss/select2.min.css?var=19285" rel="stylesheet">
<style>
.detailsPopUpHeader span {
text-transform: lowercase !important;
}
</style>
<script src="https://oss.menaitechsystems.com/IM...lude/Shared/js/shared.js?dontcash=14836338261" type="text/javascript"></script>
<script src="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/Include/Shared/js/select2.min.js"></script>

<style type="text/css">
@Font-face {
font-family: 'passwords';

src: url('https://oss.menaitechsystems.com/IM...ns/light/font/text-security-disc_password.ttf') format('truetype');
}
</style>







<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-store">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Cache-Control" content="must-revalidate">
<meta http-equiv="Cache-Control" content="max-age=0">
<meta name="Description" content=" MenaITech is the first software company in the Arab region specialized in the development and distribution of Human Resources solutions to top public and private organizations of various countries operating in the Middle East and North Africa.">
<meta name="Keywords" content=" MenaITech ,Mena, Middle East and North Africa, HR, HRMS ,Payroll, Human Resources, solutions, PHP, webinterface, webbased, IT professionals">
<title>Payroll &amp; Personnel System</title>
<script src="https://oss.menaitechsystems.com/IM.../Include/Shared/Jquery/thickbox-compressed.js"></script>
<link href="https://oss.menaitechsystems.com/IM...nclude/Shared/Jquery/Jquery_menu/thickbox.css" rel="stylesheet" type="text/css">


<link href="https://oss.menaitechsystems.com/IM.../Jquery/jScrollPane/jquery.jscrollpaneltr.css" rel="stylesheet" type="text/css" media="all">

<!-- the mousewheel plugin - optional to provide mousewheel support -->
<script src="https://oss.menaitechsystems.com/IM...hared/Jquery/jScrollPane/jquery.mousewheel.js" type="text/javascript"></script>

<!-- the jScrollPane script -->
<script src="https://oss.menaitechsystems.com/IM.../Jquery/jScrollPane/jquery.jscrollpane.min.js" type="text/javascript"></script>

<style id="page-css" type="text/css">
/* Styles specific to this particular page */
.scroll-pane
{
width: auto;
overflow: auto;
}

.vac_res
{
position:static!important;
}
.btn-group .show {
display: flex;
border: 1px solid #54575B !important;
background-color: #1D1D1B !important;
border-radius: 15px !important;
transform: none !important;
top: -10px !important;
padding-top: 9px !important;
width: 170px !important;
}
.dropright .dropdown-toggle::after {
display: none !important;
}

</style>



<div class="Main_overlay" id="Main_overlay" style="display: none; z-index: 0; opacity: 0;"></div>


<table width="100%" height="100%" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td height="1%">
<div id="TopFrameDiv">


<div style="width: 100%; height: 75px; position: relative;"><style>
#search .focus{
background-position: 13px 9px !important;

}</style>
<div style="position: relative;">
<i class="menaIcon open dropdownsys SystemArrow">Systems</i>
<i title="MenaHRMS" class="menaIcon info" onclick="about();"></i>
</div>
<div class="OtherSystems" style="direction: ltr;" opened="0">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td>
<div class="systemItems">
<a id="system_link" style="color: rgb(0, 0, 0);" href="javascript:go_to_page(1,'pay')" target="_parent">
<i class="menaIcon MenaPay"></i>
<span class="product-title">MenaPay ®</span>
</a>
</div>
<div class="systemItems">
<a id="system_link" style="color: rgb(0, 0, 0);" href="javascript:go_to_page(2,'TA')" target="_parent">
<i class="menaIcon MenaTA"></i>
<span class="product-title">MenaTA ®</span>
</a>
</div>


</td>
</tr>
</tbody></table>
<i class="menaIcon close dropdownsys SystemArrow"></i>
</div>
<div class="companyLogo">
<img name="system_r1_c1" height="50" id="system_r1_c1" alt="" src="https://oss.menaitechsystems.com/IM...anch_Logos/158064350115806435012301807465.jpg" border="0">
<div class="user_info">
<span class="welcomeAll">
<span class="welcomeUser"> <b style="color: rgb(0, 140, 255); text-transform: uppercase;">Welcome </b> Thilan ,</span>
<span class="welcomeBrance">
Imtiaz Al Arabia Co. <span title="LOGOUT" class="logout menaIcon" id="logout"></span>
</span>
</span>
<span title="Favorites" style="margin: 0px 5px;" onclick="FavFn();"><i class="menaIcon FavIcon"></i></span>
<span title="External Links" style="margin: 0px 5px 0px 0px;" onclick="ExtraLinkFn();"><i class="menaIcon ExtranlLinksIcon"></i></span>
<script src="https://oss.menaitechsystems.com/IM...ared/js/systemSearchAutocomplete.js?vars=1175" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
sendSystemSearchAjax('.seachInput',50);
});
</script>
<div title="Search" id="search">
<input class="seachInput" style="margin: 0px 5px 0px 0px;" type="search" value="" autocomplete="off">
</div>
<div class="sub_menu_box" id="systemSearchBox" style="display: none;">
<img class="close_button" id="change" src="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/skins/Light/popup/close_button.png">
<div class="MainMenuPopUpBody">
<div class="detailsPopUpHeader systemSearchBoxTitle">Search Results<div class="systemSearchBoxTitle systemSearchBoxCount">(0)</div></div>
<div class="searchtLoadingImageDiv" id="searchLoadingImageDiv">
Loading...<br><br>
<img src="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/skins/Light/loadingAnimation.gif" border="0">
</div>
<div class="searchResultSystemSearchAjax" id="searchResultSystemSearchAjax"></div>
</div>
</div>
</div>
</div>
<div style="padding: 20px; float: right;">

<div title="Dashboard" class="TopMenuIcons" id="dashboard"><i class="menaIcon dashBoard"></i> <i class="menaIcon border"></i></div>
<div title="Home Page" class="TopMenuIcons" id="home"><i class="menaIcon Home"></i> <i class="menaIcon border"></i></div>
<div title="Change" class="TopMenuIcons" id="change"><i class="menaIcon Change"></i> <i class="menaIcon border"></i></div>
<div title="System Lock" class="TopMenuIcons" id="security"><i class="menaIcon SystemLock"></i> <i class="menaIcon border"></i></div>
<div title="Inquiry" class="TopMenuIcons" id="inquiry"><i class="menaIcon inquiry"></i> <i class="menaIcon border"></i></div>
<div title="Language" class="TopMenuIcons" id="language"><i class="menaIcon Language"></i></div>
</div>
<div class="sub_menu_box" id="change_sub_menu" style="display: none;">
<i class="close_button menaIcon close_button" id="change"></i>
<table width="270" height="50" id="sub_menu_table" dir="ltr" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td class="MainMenuPopUpBody" valign="top" colspan="3px">
<center>
<div style="text-align: center;">
<i class="menaIcon Change" style="width: 30px;"></i>
<hr style="background: rgb(35, 90, 196); margin: 0px auto; border: 0px currentColor; border-image: none; width: 50px; padding-bottom: 2px;">
</div>
<div>
<div class="main_menu_sub_link" id="change_branch_div" style="width: 100%;" onclick="Show_MenaBox('fastchangebranch.php','Branch','400','180')">
<i class="menaIcon changeBranch"></i>
<br>Branch </div>
<div class="main_menu_sub_link" style="width: 100%;" onclick="Show_MenaBox('fastchangelogo.php','Logo','400','320')">
<i class="menaIcon changeLogo"></i>
<br>Logo </div>
</div>
<div>
<div class="main_menu_sub_link" style="width: 100%;" onclick="Show_MenaBox('fastchangepass.php','Password','450','275')">
<i class="menaIcon changePassword"></i>
<br>Password </div>
</div>
</center>
</td>
</tr>
</tbody></table>
</div>

<div class="sub_menu_box" id="inquery_sub_menu" style="display: none;">
<i class="close_button menaIcon close_button" id="change"></i>
<table width="270" height="250" id="sub_menu_table" dir="ltr" border="0" cellspacing="0" cellpadding="0">
<tbody><tr>
<td class="MainMenuPopUpBody" valign="top" colspan="3px">
<center>
<div style="text-align: center;">
<i class="menaIcon inquiry" style="width: 45px; padding-bottom: 10px;"></i>
<hr style="background: rgb(35, 90, 196); margin: 0px auto; border: 0px currentColor; border-image: none; width: 50px; padding-bottom: 2px;">
</div>
<div>
<div class="main_menu_sub_link" id="inquiry_emp_info">
<i class="menaIcon employee_fast_inquery"></i>
<br>Employee Fast Inquiry </div>
<div class="main_menu_sub_link" id="inquiry_emp_cost">
<i class="menaIcon inquiry_emp_cost"></i>
<br>Employee Cost </div>
</div>

<div>
<div class="main_menu_sub_link" id="inquiry_organization">
<i class="menaIcon organization_chart"></i>
<br>Organization Chart </div>
<div class="main_menu_sub_link" id="inquiry_emp_calendar">
<i class="menaIcon employee_calendar"></i>
<br>Employee Calendar </div>
</div>
</center>
</td>
</tr>
</tbody></table>
</div>

&nbsp;<script type="text/javascript">
clicked=0;
function go_to_page(type,page){
if(clicked) return false;
if(type==1){
if(page!="mename") {
clicked=1;
Show_LoadingBox();
location.replace("https://oss.menaitechsystems.com/im...832:d7f61d0f1ddcd7a48214c81a62e04cec&to_page="+page)
}
else {
window.open("https://oss.menaitechsystems.com/im...832:d7f61d0f1ddcd7a48214c81a62e04cec&to_page="+page,"_blank");
clicked=0;
}
}
else location.replace("changeToTA.php?to_page="+page);
return false;
}

</script></div>


<script>
document.onkeydown = detectKey;

function hide_sub_menu_box(a)
{
$('.sub_menu_box').css({'display':'none'});
}
function detectKey()
{
k=event.keyCode;
if(k=='121')
{
show_fast_inquiry();
}
}
</script></div>
<!--<div style="width:100%; height:50px;" id="systemMenuDiv">-->

<!-- ----------------------------------------------------------------------------------------------------------------------------------------------------------- -->
<div id="systemMenuDiv" style="width: 100%; height: 50px;"><!-- ----------------------------------------------------------------------------------------------------------------------------------------------------------- -->


<link href="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/skins/Light/MainMenu/css/style_ltr.css" rel="stylesheet" type="text/css" media="screen">
<link href="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/skins/Light/style_ltr.css" rel="stylesheet" type="text/css" media="screen">
<script src="https://oss.menaitechsystems.com/IMTIAZ/application/hrms//DB/skins/Light/MainMenu/js/cufon-yui.js" type="text/javascript"></script>
<link href="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/skins/Light/MainMenuCSS_ltr.css" rel="stylesheet" type="text/css">
<style>
ul.Main_menu > li
{
width:20%;
}
ul.Main_menu .containerDiv > ul{
width:16%;
}
ul.Main_menu .containerDiv{
width:500%;
}
</style>
<div class="Main_wrapper">
<ul class="Main_menu hovered" id="Main_menu">

<!-- Settings Part Start -->
<!-- Administrative Setup Level One -->
<li><a href="#">
<font class="dic_changeable" id="8715">Settings</font> </a>
<div class="containerDiv" id="SettingsTab" style="display: none;">
<!-- Administrative Setup Level Tow -->
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="1713">Administrative Setup</font> </li>
<!-- Administrative Setup Level Three -->
</ul>
<!-- Organizational Setup Level Tow -->
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="1714">Organizational Setup</font> </li>
<li><a href="../../../index.php/Menapay/setup/site_217" target="body_frame">
<font class="dic_changeable" id="1029">Hierarchy Setup</font> </a></li>
<li><a href="system_info/Salary_Scale_M.php" target="body_frame">
<font class="dic_changeable" id="1040">Salary Scale</font> </a></li>
<li><a href="../../../index.php/menaPay/setup/Mename_authority_level_247" target="body_frame">
<font class="dic_changeable" id="5544">Managers Permissions</font> </a></li>
<li><a href="system_info/key_staff_setup.php" target="body_frame">
<font class="dic_changeable" id="5448">Key-Staff Setup</font> </a></li>
</ul>
<!-- General Settings Level Tow -->
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="1720">General Settings</font> </li>
<li><a href="system_info/setup.php" target="body_frame">
<font class="dic_changeable" id="10">System Parameters</font> </a></li>
<li><a href="system_info/currencies.php" target="body_frame">
<font class="dic_changeable" id="1375">Currencies Setup</font> </a></li>
<li><a href="system_info/tax_discounts_routing.php" target="body_frame">
<font class="dic_changeable" id="44">Tax Law Setup</font> </a></li>
<li><a href="system_info/extra_salaries_setup.php" target="body_frame">
<font class="dic_changeable" id="2270">Extra Salaries Setup</font> </a></li>
<li>
<a href="system_info/Holidays_setup.php" target="body_frame"><font class="dic_changeable" id="2864">Holidays Setup</font></a>
</li>
<li><a href="system_info/setup_notifications.php" target="body_frame">
<font class="dic_changeable" id="2781">Notifications Setup</font> </a></li>
<li><a href="system_info/regions_setup.php" target="body_frame">
<font class="dic_changeable" id="3962">Regions Setup</font> </a></li>
<li><a href="../../../index.php/menaPay/setup/salary_slip_items_416" target="body_frame">
<font class="dic_changeable" id="3405">Salary Reports Setup</font> </a></li>
<li><a href="../../../index.php/menaPay/setup/system_theme_setup_1588" target="body_frame">
<font class="dic_changeable" id="52506">System Theme</font> </a></li>
</ul>
<ul>
<li class="Main_heading">&nbsp;</li>
<li> <a href="../../../index.php/menapay/setup/export_bank_sheet_options_1114" target="body_frame">
<font class="dic_changeable" id="5049">Banks Files Setup</font> </a></li>
<li> <a href="../../../index.php/menapay/setup/bank_salary_integration_1219" target="body_frame">
<font class="dic_changeable" id="11757">Bank Integration Setup</font> </a></li>
<li> <a href="../../../index.php/menaPay/setup/signature_name_608" target="body_frame">
<font class="dic_changeable" id="5013">Signatures Setup</font> </a></li>
<li><a href="system_info/pay_budget_setup.php" target="body_frame">
<font class="dic_changeable" id="5039">Budget Setup</font> </a></li>
<li><a href="system_info/Dynamic_lists_setup.php" target="body_frame">
<font class="dic_changeable" id="4473">Dynamic Lists Setup</font> </a></li>
<li><a href="../../../index.php/MenaPay/setup/Attachments_size_setup_1013" target="body_frame">
<font class="dic_changeable" id="5533">Attachments Setup</font> </a></li>
<li><a href="system_info/goverment_category.php" target="body_frame">
<font class="dic_changeable" id="5904">Government Setup</font> </a></li>
<li><a href="../../../index.php/menaPay/setup/bonus_setup_952" target="body_frame">

<font class="dic_changeable" id="9727">Bonus Setup</font> </a></li>
<li><a href="externallinks/externallinks.php" target="body_frame">
<font class="dic_changeable" id="6905">External Links Setup</font> </a></li>
<li><a href="system_info/saudization_setup.php" target="body_frame">
<font class="dic_changeable" id="11514">Saudization Setup</font> </a></li>
</ul>
<!-- Workflow Setup Level Tow -->
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="5445">Workflow Setup</font> </li>
<li><a href="../../../index.php/menaPay/setup/workflow_options_879" target="body_frame">
<font class="dic_changeable" id="5445">Workflow Setup</font> </a></li>
<li><a href="Workflow/workflow_assign.php" target="body_frame">
<font class="dic_changeable" id="5451">Workflow Assign</font> </a></li>
<li><a href="Workflow/WF_screening.php" target="body_frame">
<font class="dic_changeable" id="5466">Workflow Screening</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/WF_report_739" target="body_frame">
<font class="dic_changeable" id="6630">Workflow Report</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/WF_template_report_783" target="body_frame">
<font class="dic_changeable" id="7147">WF Templates Report</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/WF_setup_1147" target="body_frame">
<font class="dic_changeable" id="11332">Detailed WF Templates Report</font> </a></li>
</ul>
<!-- Employees Setup Level Tow -->
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="177">Employees Setup</font> </li>
<li><a href="../../../index.php/menaPay/setup/job_family_setup_321" target="body_frame">
<font class="dic_changeable" id="678">Personnel Setup</font> </a></li>
<li><a href="../../../index.php/menaPay/setup/finace_information_setup_24" target="body_frame">
<font class="dic_changeable" id="127">Financial Setup</font> </a></li>
</ul>
</div>
</li>
<!-- Settings Part End -->

<!-- Employees Part Start -->
<!-- Employees Setup Level One Start -->
<li class="hovered"><a href="#">
<font class="dic_changeable" id="236">Employees</font> </a>
<!-- Employees Setup Level Tow -->
<div class="containerDiv" id="EmploeesTab" style="left: -100%; display: none; z-index: 1;">
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="8717">Main Information</font> </li>
<li><a href="employees/employees.php" target="body_frame">
<font class="dic_changeable" id="237">Personnel Information</font> </a></li>
<li><a href="employees/allownce.php" target="body_frame">
<font class="dic_changeable" id="1030">Financial Information</font> </a></li>
</ul>
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="2145">Extra Information</font> </li>
<li><a href="employees/mass_allowances.php" target="body_frame">
<font class="dic_changeable" id="5722">Mass Allowances</font> </a></li>
<li><a href="employees/residences_setup.php" target="body_frame">
<font class="dic_changeable" id="4425">Employees Residences</font> </a></li>
<li><a href="employees/alternatives.php" target="body_frame">
<font class="dic_changeable" id="3663">Substitutes</font> </a></li>
<li><a href="employees/HR_Job_App_Exams.php" target="body_frame">
<font class="dic_changeable" id="5611">Application Exams </font> </a></li>
<li><a href="employees/HR_App_exams_import.php" target="body_frame">
<font class="dic_changeable" id="5617">Import Application Exams</font> </a></li>
<li><a href="employees/Cost_center_import.php" target="body_frame">
<font class="dic_changeable" id="5667">Cost Centers Import</font> </a></li>
<li><a href="employees/covered_deductions.php" target="body_frame">
<font class="dic_changeable" id="3674">Covered Deductions</font> </a></li>
<li><a href="employees/employees_provisions.php" target="body_frame">
<font class="dic_changeable" id="4916">Dynamic Provisions Distribution</font> </a></li>
<li><a href="employees/pay_emp_notifications.php" target="body_frame">
<font class="dic_changeable" id="3012">Employees Greetings</font> </a></li>

</ul>
<ul>
<li class="Main_heading">&nbsp;</li>

<li><a href=" employees/dynamic_allowances_import.php" target="body_frame">
<font class="dic_changeable" id="10634">Monthly KPI Import</font> </a></li>
<li><a href="employees/employee_information_import.php" target="body_frame">
<font class="dic_changeable" id="10269">Import Employees</font> </a></li>
<li><a href="employees/get_employees.php" target="body_frame">
<font class="dic_changeable" id="12700">Import Employees - Integration</font> </a></li>
</ul>
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="2148">Lock Employees Data</font> </li>
<li><a href="transactions/lock_financial_data.php" target="body_frame">
<font class="dic_changeable" id="2148">Lock Employees Data</font> </a></li>
</ul>
</div>
</li>
<!-- Employees Setup End -->

<!-- Workforce Management Setup Level One Start -->
<li><a href="#">
<font class="dic_changeable" id="8726">Workforce Management</font> </a>
<div class="containerDiv" style="left: -200%; display: none;">
<!-- Leave Management Module -->
<ul>
<li class="Main_heading">
<font class="dic_changeable" id="2597">Leave Management </font> </li>
<li><a href="../../../index.php/MenaPay/setup/leaves_module_setup_548" target="body_frame">
<font class="dic_changeable" id="11">Setup</font> </a></li>
<li><a href="employees/vacations.php" target="body_frame">
<font class="dic_changeable" id="1991">Vacations Balances</font> </a></li>
<li><a href="transactions/hourlyleaves.php" target="body_frame">
<font class="dic_changeable" id="337">Employees Transactions</font> </a></li>
<li><a href="transactions/data_load_leave.php" target="body_frame">
<font class="dic_changeable" id="2896">Tabular Entry</font> </a></li>
<li><a href="transactions/expansion_vac_advance_trans.php" target="body_frame">
<font class="dic_changeable" id="3699">Vacation In Advance Screening</font> </a></li>
<li><a href="transactions/vacations_resumption.php" target="body_frame">
<font class="dic_changeable" id="6819">Vacations Resumption</font> </a></li>
<li><a href="transactions/open_financial_year.php" target="body_frame">
<font class="dic_changeable" id="2156">Vacation Balances Moving</font> </a></li>
</ul>
<ul>
<li class="Main_heading">&nbsp;</li>
<li><a href="transactions/move_vac_balance_diff.php" target="body_frame">
<font class="dic_changeable" id="4564">Vacations Balances Differences</font> </a></li>
<li><a href="transactions/round_leave_to_vacations.php" target="body_frame">
<font class="dic_changeable" id="3038">Round Leave</font> </a></li>
<li><a href="transactions/movetransactions_leave_manag.php" target="body_frame">
<font class="dic_changeable" id="468">Posting &amp; Unposting</font> </a></li>
<li class="subitems"><img src="https://oss.menaitechsystems.com/IMTIAZ/application/hrms/DB/skins/Light/icons/subMenuIcon.png"><a href="#">
<font class="dic_changeable" id="413">Reports</font> </a>
<div class="Main_menu_lv4">
<ul>
<li><a href="../../../index.php/MenaPay/reports/leaves_transactions_report_1203" target="body_frame">
<font class="dic_changeable" id="473">Employee Transactions</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/vacations_balance_report_118" target="body_frame">
<font class="dic_changeable" id="1466">Vacations Balances</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/vacations_sheet_238" target="body_frame">
<font class="dic_changeable" id="2871">Vacations Sheet</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/vacations_summary_239" target="body_frame">
<font class="dic_changeable" id="2874">Vacations Summary</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/vacations_report_432" target="body_frame">
<font class="dic_changeable" id="4089">Vacations Totals</font> </a></li>

<li><a href="../../../index.php/MenaPay/reports/vacation_resumption_report_583" target="body_frame">
<font class="dic_changeable" id="4740">Vacation Resumption Report </font> </a></li>
<li><a href="reports/vac_inadvance_satlement_report.php" target="body_frame">
<font class="dic_changeable" id="7683">In-Advance Settlement Report</font> </a></li>
<li><a href="../../../index.php/MenaPay/reports/screening_leave_vacation_report_688" target="body_frame">
<font class="dic_changeable" id="5562">Leave/Vacation Requests</font> </a></li>
<li><a href="reports/vacation_ticket_report.php" target="body_frame">
<font class="dic_changeable" id="5271">Vacation/Ticket Form</font> </a></li>
<li><a href="reports/sick_vacations.php" target="body_frame">
<font class="dic_changeable" id="10764">Sick Vacations Report</font> </a></li>
 
Upvote 0
So it contains 2 iframes, one named "body_frame" and the other isn't shown, though it's possibly related to <div id="TopFrameDiv">

Add a reference to Microsoft HTML Object Library, via Tools -> References in the VBA editor and put this code after the IE page has completely loaded to identify the iframe containing the employee code input element:
VBA Code:
    Dim HTMLdocMain As HTMLDocument, HTMLdoc As HTMLDocument
    Dim iframe As HTMLIFrame
    Dim employeeInput As HTMLInputElement
    Set HTMLdocMain = IE.document
    For Each iframe In HTMLdocMain.getElementsByTagName("iframe")
        Set HTMLdoc = iframe.document
        Set employeeInput = Nothing
        On Error Resume Next
        Set employeeInput = HTMLdoc.getElementById("employee_code")
        On Error GoTo 0
        If Not employeeInput Is Nothing Then Exit For
    Next
    If Not employeeInput Is Nothing Then
        employeeInput.Value = "2631"
        MsgBox "Employee code input element found in iframe: id=" & iframe.ID & ", name=" & iframe.Name & ", src=" & iframe.src
        'From this point, use HTMLdoc to access elements in this iframe document
    Else
        MsgBox "Employee code input element not found"
    End If
    Stop
 
Upvote 0
So it contains 2 iframes, one named "body_frame" and the other isn't shown, though it's possibly related to <div id="TopFrameDiv">

Add a reference to Microsoft HTML Object Library, via Tools -> References in the VBA editor and put this code after the IE page has completely loaded to identify the iframe containing the employee code input element:
VBA Code:
    Dim HTMLdocMain As HTMLDocument, HTMLdoc As HTMLDocument
    Dim iframe As HTMLIFrame
    Dim employeeInput As HTMLInputElement
    Set HTMLdocMain = IE.document
    For Each iframe In HTMLdocMain.getElementsByTagName("iframe")
        Set HTMLdoc = iframe.document
        Set employeeInput = Nothing
        On Error Resume Next
        Set employeeInput = HTMLdoc.getElementById("employee_code")
        On Error GoTo 0
        If Not employeeInput Is Nothing Then Exit For
    Next
    If Not employeeInput Is Nothing Then
        employeeInput.Value = "2631"
        MsgBox "Employee code input element found in iframe: id=" & iframe.ID & ", name=" & iframe.Name & ", src=" & iframe.src
        'From this point, use HTMLdoc to access elements in this iframe document
    Else
        MsgBox "Employee code input element not found"
    End If
    Stop
here is the message

1648491256782.png
 
Upvote 0

Forum statistics

Threads
1,215,461
Messages
6,124,957
Members
449,200
Latest member
indiansth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top