1

I have a macro that load a webpage where I have to enter in a field the startdate and enddate of a range of days. At the right of the fields there is a button that shows a calendar(grid) where you can click to choose the startdate and enddate.

If I enter it via VBA, it displays a message box "You have to enter the choosen dates to display the table." If I enter it with the buttons, it works fine. There is my code:

Sub Sail3()


Dim ie      As Object
Dim frm     As Variant
Dim element As Variant
Dim datesail As String

Set ie = New InternetExplorerMedium


ie.navigate "http://pfrwtekref/websail/"

While ie.readyState <> 4: DoEvents: Wend

Set frm = ie.document.getElementById("Form1")

   ie.Visible = True
   ie.document.getElementById("Form1").elements("txtLogin").Value = ----private
   ie.document.getElementById("Form1").elements("txtPwd").Value = -----------private
   ie.document.getElementById("Form1").elements("Button1").Click
   ie.navigate "http://pfrwtekref/websail/frmSuiviActivite2.aspx"
   
While ie.readyState <> 4: DoEvents: Wend

    ie.document.getElementById("Form1").elements("DateDebut").Value = Date
    ie.document.getElementById("Form1").elements("DateFin").Value = Date
    ie.document.getElementById("Form1").elements("btn_Resultat").Click

End Sub

And there is screenshots of the webpage: -Via vba (not working) enter image description here

-With the buttons (working) enter image description here Code before clicking on "Choix3 (to choose the date)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD><title>
    Suivi d'activité
</title><meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"><meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"><meta content="JavaScript" name="vs_defaultClientScript"><meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"><link href="styles.css" type="text/css" rel="stylesheet" /></HEAD>
    <body MS_POSITIONING="GridLayout">
        <form name="Form1" method="post" action="./frmSuiviActivite2.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTMxMzIxNTY2D2QWAgIDD2QWAgISDzwrAAsAZGScOQoNqGNqyktNdNb5duOihHfSXDhXwJMIdrEy+WJPjQ==" />

<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="BC9C9B4F" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAfLmZQgUyFrp+RtWRcn8WdyGhTo+VLfEoiQDWerbcGjiKDfFJNoZm2vzKsM7PzPDpwulGLYm9lXIP2asThkLC1apobPVZ60uUnrD2vRXyjteTbfGbMKwn+GJo6LfUjoxo88T+xOKs2R9iIIXy/DTbdWjeFlT81n+dvcqoy+Mi28ir9R143smwIFKGM/CiVtiqM=" />
            <span id="Label1" style="font-weight:bold;Z-INDEX: 100; LEFT: 128px; POSITION: absolute; TOP: 144px">Date de début :</span>
            <input type="submit" name="btn_Quitter" value="Quitter" id="btn_Quitter" class="MyBoutonQuitter" style="width:121px;Z-INDEX: 112; LEFT: 720px; POSITION: absolute; TOP: 72px" /><span id="Label3" class="MyTitre" style="width:224px;Z-INDEX: 105; LEFT: 330px; POSITION: absolute; TOP: 60px">Suivi d'activité</span>
            <span id="Label2" style="font-weight:bold;Z-INDEX: 101; LEFT: 400px; POSITION: absolute; TOP: 144px">Date de fin :</span>
            <input name="DateDebut" type="text" readonly="readonly" id="DateDebut" style="Z-INDEX: 102; LEFT: 128px; POSITION: absolute; TOP: 168px" />
            <input name="DateFin" type="text" readonly="readonly" id="DateFin" style="Z-INDEX: 103; LEFT: 400px; POSITION: absolute; TOP: 168px" />
            <input type="submit" name="btn_ChoixDebut" value="Choix" id="btn_ChoixDebut" class="MyBoutonChoix" style="width:80px;Z-INDEX: 106; LEFT: 288px; POSITION: absolute; TOP: 168px" />
            <input type="submit" name="btnChoixFin" value="Choix" id="btnChoixFin" class="MyBoutonChoix" style="width:80px;Z-INDEX: 104; LEFT: 560px; POSITION: absolute; TOP: 168px" />
            
            <input type="submit" name="btn_Resultat" value="Resultat" id="btn_Resultat" class="MyBoutonResultat" style="Z-INDEX: 109; LEFT: 665px; POSITION: absolute; TOP: 168px" /></form>
    </body>
</HTML>

Code after pressing "Choix":

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD><title>
    Suivi d'activité
</title><meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"><meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"><meta content="JavaScript" name="vs_defaultClientScript"><meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"><link href="styles.css" type="text/css" rel="stylesheet" /></HEAD>
    <body MS_POSITIONING="GridLayout">
        <form name="Form1" method="post" action="./frmSuiviActivite2.aspx" id="Form1">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTMxMzIxNTY2D2QWAgIDD2QWBAIHDzwrAAoBAA8WAh4HVmlzaWJsZWdkZAISDzwrAAsAZGQo+b6VGPdlaLrfd+6qWWHge+Ke74Fr3jjEbH6mfUec8w==" />

<script type="text/javascript">
<!--
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</script>


<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="BC9C9B4F" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdADOztrz0Gg6bn5+0Kl9l3uwKGhTo+VLfEoiQDWerbcGjiFoZONyZ6BSK3tMN8GplmUQxiPjZiofWtUlJULh4AdTbfRWuWAxRXzxvcKc1Zc+mOWOPZwnWqionmbDSbiZkc+tUfXxU9/wS+RPOpYtmV8nbw7Ukm0kQjVMZCc/YCgExUQjyuRl6qtGOIAF5EKoHRfSdEUb8hFuKHe+kl46W8n/9iwdjB2dhwgnbAsk79BDu6dAmNwyizE5+CDxjaKolTpybHan5sGI8vcqFHRtyO9j3idO9k97GrbFLq0lqy7I5uwJUg3LxVBnp0jTXUc25DpQeuA0BIkQiaSJuPN/LGglVcwRUWnjLpjUWdiF1zNiE3O+SdNDXv15A9LUvRj+6QYrkUpPqxC67c039+Yt45W2TxDM8a2vNFe+tTh79R+zb5vvPBcsBbCThBfE/C79ruLDg1DJ+DUWy+ZQLvnukpIOaysup67s2O21Yt2LIVvx+IdDifzoT1d4fbeB2FFWPB6bnMbGw/fFhCdJfgs+NlIi8DkBweRdZ5EDWNPGdenNqradH2x3djttuXeOQWc+tLPqTExYWHQVlWrqaqPaFWtfsFfqHHwWvHWtPuA9+ZqyRf6S9zC5vtwh3zJCMu+iJOopiRA3i0mbQsFn9282DbtCgVeSaFhfMGDeBRCiX1veTskxJug4XARY/xWT+UYuu+M0ul3Cpqboc3tndvQPF1sFh7Du9CPQxiANH/kg1nVCM9AkHKegiqd06oA8w0wl40V9HHMKejpwrqf0azqgpenAyS4Wg+W7v9c+zzudU8v8VIY3Y/+yR+sbxvUi4YcUvFzCEj0ki5TGsMyr6Ny70jbnaueoOTXWN05ii+YfOd7l5JoexTMqVgccCkpbAj3a2VZ31qbCIm6D3HkFCCC0W+015JiT75TYuRCmsL70MfigQZEEvJO8g6NZ0ZX3RU/vvtbmkDRPF7vgROkjGGwilflHioN8Uk2hmba/Mqwzs/M8OnC6UYtib2Vcg/ZqxOGQsLVqmhs9VnrS5SesPa9FfKO15Nt8ZswrCf4Ymjot9SOjGjzxP7E4qzZH2IghfL8NNt1bsWPsJqCXd08gjpdyjrcdCUr+5OJbuiSuKIdMC6u25DQ==" />
            <span id="Label1" style="font-weight:bold;Z-INDEX: 100; LEFT: 128px; POSITION: absolute; TOP: 144px">Date de début :</span>
            <input type="submit" name="btn_Quitter" value="Quitter" id="btn_Quitter" class="MyBoutonQuitter" style="width:121px;Z-INDEX: 112; LEFT: 720px; POSITION: absolute; TOP: 72px" /><span id="Label3" class="MyTitre" style="width:224px;Z-INDEX: 105; LEFT: 330px; POSITION: absolute; TOP: 60px">Suivi d'activité</span>
            <table id="Calendar1" tabindex="2" cellspacing="0" cellpadding="0" title="Calendar" bordercolor="#999999" border="0" style="width:208px;height:136px;font-size:8pt;font-family:Times New Roman;color:Black;border-width:1px;border-style:solid;border-color:#999999;background-color:White;border-collapse:collapse;Z-INDEX: 110; LEFT: 128px; POSITION: absolute; TOP: 200px">
    <tr><td colspan="7" style="background-color:Gold;border-color:Black;"><table cellspacing="0" border="0" style="color:Black;font-family:Times New Roman;font-size:8pt;font-weight:bold;width:100%;border-collapse:collapse;">
        <tr><td valign="bottom" style="width:15%;"><a href="javascript:__doPostBack('Calendar1','V7852')" style="color:Black" title="Go to the previous month">&lt;</a></td><td align="center" style="width:70%;">août 2021</td><td align="right" valign="bottom" style="width:15%;"><a href="javascript:__doPostBack('Calendar1','V7914')" style="color:Black" title="Go to the next month">&gt;</a></td></tr>
    </table></td></tr><tr><th align="center" abbr="lundi" scope="col" style="background-color:#CCCCCC;font-size:7pt;font-weight:bold;">l</th><th align="center" abbr="mardi" scope="col" style="background-color:#CCCCCC;font-size:7pt;font-weight:bold;">m</th><th align="center" abbr="mercredi" scope="col" style="background-color:#CCCCCC;font-size:7pt;font-weight:bold;">m</th><th align="center" abbr="jeudi" scope="col" style="background-color:#CCCCCC;font-size:7pt;font-weight:bold;">j</th><th align="center" abbr="vendredi" scope="col" style="background-color:#CCCCCC;font-size:7pt;font-weight:bold;">v</th><th align="center" abbr="samedi" scope="col" style="background-color:#CCCCCC;font-size:7pt;font-weight:bold;">s</th><th align="center" abbr="dimanche" scope="col" style="background-color:#CCCCCC;font-size:7pt;font-weight:bold;">d</th></tr><tr><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7877')" style="color:Gray" title="26 juillet">26</a></td><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7878')" style="color:Gray" title="27 juillet">27</a></td><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7879')" style="color:Gray" title="28 juillet">28</a></td><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7880')" style="color:Gray" title="29 juillet">29</a></td><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7881')" style="color:Gray" title="30 juillet">30</a></td><td align="center" style="color:Gray;background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7882')" style="color:Gray" title="31 juillet">31</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7883')" style="color:Black" title="1 août">1</a></td></tr><tr><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7884')" style="color:Black" title="2 août">2</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7885')" style="color:Black" title="3 août">3</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7886')" style="color:Black" title="4 août">4</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7887')" style="color:Black" title="5 août">5</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7888')" style="color:Black" title="6 août">6</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7889')" style="color:Black" title="7 août">7</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7890')" style="color:Black" title="8 août">8</a></td></tr><tr><td align="center" style="color:Black;background-color:#CCCCCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7891')" style="color:Black" title="9 août">9</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7892')" style="color:Black" title="10 août">10</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7893')" style="color:Black" title="11 août">11</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7894')" style="color:Black" title="12 août">12</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7895')" style="color:Black" title="13 août">13</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7896')" style="color:Black" title="14 août">14</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7897')" style="color:Black" title="15 août">15</a></td></tr><tr><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7898')" style="color:Black" title="16 août">16</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7899')" style="color:Black" title="17 août">17</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7900')" style="color:Black" title="18 août">18</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7901')" style="color:Black" title="19 août">19</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7902')" style="color:Black" title="20 août">20</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7903')" style="color:Black" title="21 août">21</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7904')" style="color:Black" title="22 août">22</a></td></tr><tr><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7905')" style="color:Black" title="23 août">23</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7906')" style="color:Black" title="24 août">24</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7907')" style="color:Black" title="25 août">25</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7908')" style="color:Black" title="26 août">26</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7909')" style="color:Black" title="27 août">27</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7910')" style="color:Black" title="28 août">28</a></td><td align="center" style="background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7911')" style="color:Black" title="29 août">29</a></td></tr><tr><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7912')" style="color:Black" title="30 août">30</a></td><td align="center" style="width:14%;"><a href="javascript:__doPostBack('Calendar1','7913')" style="color:Black" title="31 août">31</a></td><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7914')" style="color:Gray" title="1 septembre">1</a></td><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7915')" style="color:Gray" title="2 septembre">2</a></td><td align="center" style="color:Gray;width:14%;"><a href="javascript:__doPostBack('Calendar1','7916')" style="color:Gray" title="3 septembre">3</a></td><td align="center" style="color:Gray;background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7917')" style="color:Gray" title="4 septembre">4</a></td><td align="center" style="color:Gray;background-color:#FFFFCC;width:14%;"><a href="javascript:__doPostBack('Calendar1','7918')" style="color:Gray" title="5 septembre">5</a></td></tr>
</table><span id="Label2" style="font-weight:bold;Z-INDEX: 101; LEFT: 400px; POSITION: absolute; TOP: 144px">Date de fin :</span>
            <input name="DateDebut" type="text" readonly="readonly" id="DateDebut" style="Z-INDEX: 102; LEFT: 128px; POSITION: absolute; TOP: 168px" />
            <input name="DateFin" type="text" readonly="readonly" id="DateFin" style="Z-INDEX: 103; LEFT: 400px; POSITION: absolute; TOP: 168px" />
            <input type="submit" name="btn_ChoixDebut" value="Choix" id="btn_ChoixDebut" class="MyBoutonChoix" style="width:80px;Z-INDEX: 106; LEFT: 288px; POSITION: absolute; TOP: 168px" />
            <input type="submit" name="btnChoixFin" value="Choix" id="btnChoixFin" class="MyBoutonChoix" style="width:80px;Z-INDEX: 104; LEFT: 560px; POSITION: absolute; TOP: 168px" />
            
            <input type="submit" name="btn_Resultat" value="Resultat" id="btn_Resultat" class="MyBoutonResultat" style="Z-INDEX: 109; LEFT: 665px; POSITION: absolute; TOP: 168px" /></form>
    </body>
</HTML>

Code after choosing the dates:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
    <HEAD><title>
    Suivi d'activité
</title><meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR"><meta content="Visual Basic .NET 7.1" name="CODE_LANGUAGE"><meta content="JavaScript" name="vs_defaultClientScript"><meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema"><link href="styles.css" type="text/css" rel="stylesheet" /></HEAD>
    <body MS_POSITIONING="GridLayout">
        <form name="Form1" method="post" action="./frmSuiviActivite2.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTMxMzIxNTY2D2QWAgIDD2QWCgIGDzwrAAoBAA8WBB4HVmlzaWJsZWgeAlNEFgEGAEBQIm1Y2QhkZAIHDzwrAAoBAA8WBB8AaB8BFgEGAEBQIm1Y2QhkZAIKDw8WAh4EVGV4dAUKMDYvMDgvMjAyMWRkAgwPDxYCHwIFCjA2LzA4LzIwMjFkZAISDxQrAAsPFgoeCERhdGFLZXlzFgAeC18hSXRlbUNvdW50AgEeCVBhZ2VDb3VudAIBHhVfIURhdGFTb3VyY2VJdGVtQ291bnQCAR8AZ2RkZBYEHghDc3NDbGFzcwUQTXlEYXRhZ3JpZEhlYWRlch4EXyFTQgICZBYEHwcFDk15RGF0YWdyaWRJdGVtHwgCAmQWBB8HBRZNeURhdGFncmlkU2VsZWN0ZWRJdGVtHwgCAmQWBB8HBQpNeURhdGFncmlkHwgCAhQrAAY8KwAEAQAWCB4KSGVhZGVyVGV4dAUERGF0ZR4JRGF0YUZpZWxkBQREYXRlHg5Tb3J0RXhwcmVzc2lvbgUERGF0ZR4IUmVhZE9ubHloPCsABAEAFggfCQURQ2FydG9ucyBTVEQgLyBDQU8fCgURQ2FydG9ucyBTVEQgLyBDQU8fCwURQ2FydG9ucyBTVEQgLyBDQU8fDGg8KwAEAQAWCB8JBRJQYWxldHRlcyBTVEQgLyBDQU8fCgUSUGFsZXR0ZXMgU1REIC8gQ0FPHwsFElBhbGV0dGVzIFNURCAvIENBTx8MaDwrAAQBABYIHwkFEkTDqXZvecOpIFNURCAvIENBTx8KBRJEw6l2b3nDqSBTVEQgLyBDQU8fCwUSRMOpdm95w6kgU1REIC8gQ0FPHwxoPCsABAEAFggfCQURVG9ubmFnZSBTVEQgLyBDQU8fCgURVG9ubmFnZSBTVEQgLyBDQU8fCwURVG9ubmFnZSBTVEQgLyBDQU8fDGg8KwAEAQAWCB8JBRBMaWduZXMgU1REIC8gQ0FPHwoFEExpZ25lcyBTVEQgLyBDQU8fCwUQTGlnbmVzIFNURCAvIENBTx8MaBYCZg9kFgICAQ9kFgxmDw8WAh8CBRN2ZW5kcmVkaSAwNi8wOC8yMDIxZGQCAQ8PFgIfAgUHMjE2IC8gMGRkAgIPDxYCHwIFBjI5IC8gMGRkAgMPDxYCHwIFBjIzIC8gMGRkAgQPDxYCHwIFCDMsMzkgLyAwZGQCBQ8PFgIfAgUIMTA3OCAvIDBkZGRgZ1VBvgcvb3OcHEfjrBeFK/x2Kv/FGT3UrGXvxzDbcw==" />

<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="BC9C9B4F" />
<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEdAAe9tF3Oa7CP1zw1oQDDCiBAGhTo+VLfEoiQDWerbcGjiKDfFJNoZm2vzKsM7PzPDpwulGLYm9lXIP2asThkLC1apobPVZ60uUnrD2vRXyjteTbfGbMKwn+GJo6LfUjoxo88T+xOKs2R9iIIXy/DTbdWg1gvqgNQzBkfcXFpD53EF73X2sza3EXD3gHd2X+ykW8=" />
            <span id="Label1" style="font-weight:bold;Z-INDEX: 100; LEFT: 128px; POSITION: absolute; TOP: 144px">Date de début :</span>
            <input type="submit" name="btn_Quitter" value="Quitter" id="btn_Quitter" class="MyBoutonQuitter" style="width:121px;Z-INDEX: 112; LEFT: 720px; POSITION: absolute; TOP: 72px" /><span id="Label3" class="MyTitre" style="width:224px;Z-INDEX: 105; LEFT: 330px; POSITION: absolute; TOP: 60px">Suivi d'activité</span>
            <span id="Label2" style="font-weight:bold;Z-INDEX: 101; LEFT: 400px; POSITION: absolute; TOP: 144px">Date de fin :</span>
            <input name="DateDebut" type="text" value="06/08/2021" readonly="readonly" id="DateDebut" style="Z-INDEX: 102; LEFT: 128px; POSITION: absolute; TOP: 168px" />
            <input name="DateFin" type="text" value="06/08/2021" readonly="readonly" id="DateFin" style="Z-INDEX: 103; LEFT: 400px; POSITION: absolute; TOP: 168px" />
            <input type="submit" name="btn_ChoixDebut" value="Choix" id="btn_ChoixDebut" class="MyBoutonChoix" style="width:80px;Z-INDEX: 106; LEFT: 288px; POSITION: absolute; TOP: 168px" />
            <input type="submit" name="btnChoixFin" value="Choix" id="btnChoixFin" class="MyBoutonChoix" style="width:80px;Z-INDEX: 104; LEFT: 560px; POSITION: absolute; TOP: 168px" />
            <table class="MyDatagrid" cellspacing="0" rules="all" border="1" id="dgMainGrid" style="border-style:Solid;width:824px;border-collapse:collapse;Z-INDEX: 107; LEFT: 128px; POSITION: absolute; TOP: 240px">
    <tr class="MyDatagridHeader">
        <td>Date</td><td>Cartons STD / CAO</td><td>Palettes STD / CAO</td><td>Dévoyé STD / CAO</td><td>Tonnage STD / CAO</td><td>Lignes STD / CAO</td>
    </tr><tr class="MyDatagridItem">
        <td>vendredi 06/08/2021</td><td>216 / 0</td><td>29 / 0</td><td>23 / 0</td><td>3,39 / 0</td><td>1078 / 0</td>
    </tr>
</table>
            <input type="submit" name="btn_Resultat" value="Resultat" id="btn_Resultat" class="MyBoutonResultat" style="Z-INDEX: 109; LEFT: 665px; POSITION: absolute; TOP: 168px" /></form>
    </body>
</HTML>

Edit: As some of you made the remark, Yes, even with the "good" date format it still dont work, I think it's because the "input" fields are not really for input, they just display the selected dates, in reality the dates are taken from the calendar. That's why even with the good date format it tells me that i didn't enter any dates

Edit2: code added I can't find I solution, do you have any ideas ? Thanks for reading and have a good day ! (sorry for my bad english)

babozo
  • 71
  • 9
  • Have you tried formatting the date in vba so that they are the same as when you use it without? They look different formats on the images you provided. Try using `Format(Date, "dd/MM/yyyy")` instead of `Date` – Joe Aug 06 '21 at 14:29
  • There's no 1 standard way of doing this but passing `Date` as it is should be wrong, try passing `Date` as a string in the format it wants so `Format(Date,"dd/mm/yyyy")` – Raymond Wu Aug 06 '21 at 14:30
  • @RaymondWu & Joe-j : yes, even with the "good" date format it still dont work, I think it's because the "input" fields are not really for input, they just display the selected dates, in reality the dates are taken from the calendar. That's why even with the good date format it tells me that i didn't enter any dates.. – babozo Aug 06 '21 at 15:01
  • 2
    @babozo I can't access the website so it's difficult to tell you how to get it work without being able to test. Perhaps edit your question and provide the html code _might_ help. – Raymond Wu Aug 06 '21 at 15:06
  • 1
    It's possible you must trigger html events to make the dates work for the page. You can look here how you can do that and on the screenshots on the bottom of the posting how to check if there are events and how to look which ones: https://stackoverflow.com/questions/63294113/automate-ie-via-excel-to-fill-in-a-dropdown-and-continue/63299608#63299608 – Zwenn Aug 07 '21 at 09:31
  • I think it triggers some events when you click the button. After the events, the date input is considered to be activated. That's why it only works with the buttons. If clicking the button works, then I think you can use it in VBA. We can't access the website you provied. If you have any other issues, you need to provide the html code of the page so that we can investigate. – Yu Zhou Aug 09 '21 at 03:10
  • That's what I was thinking. I dont know how to trigger events or how to find wich event to trigger so i tried to click on the buttons "choix" (to trigger the event) and to input the dates after but it still didn't work... Anyway, code added, I appreciate your help, thanks to all of you!! – babozo Aug 09 '21 at 06:34

1 Answers1

1

I have finally found a solution !! When I press the button "Choix" there is an event that is triggered wich make this function appear in the code

<script type="text/javascript">
<!--
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</script>

Then I just had to send the values "Calendar1" or "Calendar2" as eventTarget and the date (in java format) as eventArgument to the __doPostBack function just like that:

Set currentWdw = .document.parentWindow
    With currentWdw
    Application.Wait Now + TimeValue("0:00:01")
    .execScript ("__doPostBack('Calendar1','" & datesail & "')")
    Application.Wait Now + TimeValue("0:00:01")
    .execScript ("__doPostBack('Calendar2','" & datesail & "')")
    End With

This is a very specific case but I hope this answer will help someone in the future.

Have a good day !

babozo
  • 71
  • 9