2

I want to Login to a Webinterface of a Simatic Panel. Next Step should get the Errorarchiv.csv files I want to Open them and get the Error Logs. With another macro i will sort them --> This works!

<form style="padding:0px; margin:0px; border:0px; background:#b8b8ff"
method="POST"
id="LoginForm"
name="LoginForm"
action="/FormLogin"><table width="116" border="0" cellspacing="0" cellpadding="0"><tr><td width="52" height="13" align="right" valign="bottom" style="font-size:10px;">Name</td>
<td width="52"><input name="Login" type="text" style="width:52px;height:13px;margin: 6px 6px 0 6px; padding:0px; border:0px;font-size:10px;"></td></tr>
<tr><td width="52" height="13" align="right" valign="bottom" style="font-size:10px;">Passwort</td><td width="52">
<input name="Token" type="hidden" value="%=Token">
<input name="Redirection" type="hidden">
<input name="Password" type="password" style="width:52px;height:13px;margin:6px 6px 0 6px; padding:0px; border:0px;font-size:10px;"></td></tr>
<tr><td colspan="2" align="right"><input type="submit" value="Login" style="margin:3px 6px 6px 6px; padding:0px; border:0px; font-size:10px; color: #000080; background-color:#b8b8ff;text-decoration:underline;"></td></tr></table></form><script type="text/javascript">
LoginForm.Login.focus();LoginForm.Redirection.value=location.href.split("?Redirection=").pop();
</script>  

This code works:

Adresse = "http://10.100.200.31/"
 'Explorer auf seite öfnen
Set Ie = CreateObject("InternetExplorer.Application")
Ie.Visible = True
 Ie.navigate Adresse & "StorageCardSD/Logs?UP=TRUE&FORCEBROWSE"
Do While Ie.readyState <> 4
    DoEvents
Loop
On Error GoTo Eingeloggt
 Ie.document.forms(0).elements("Login").Value = "Administrator"
 Ie.document.forms(0).elements("Password").Value = "4311"
 Ie.document.forms(0).submit
Eingeloggt:
'Mehrere Fensterwechsel
Do: Loop Until Ie.Busy = False
Do: Loop Until Ie.Busy = False
Do: Loop Until Ie.Busy = False
Do: Loop Until Ie.Busy = False

But i don't know how to download the *.csv; Navigate to the link opens the SaveAs Window

<td><img onclick='Open("/StorageCardSD/Logs/Meldearchiv_20.csv")' src="/Images/File.gif"></td>
<td><a href="/StorageCardSD/Logs/Meldearchiv_20.csv?UP=TRUE&amp;FORCEBROWSE">Meldearchiv_20.csv</a></td>
<td>1136 K</td>
<td>-R--A--</td>
<td>Tue May 19 12:13:52 2020</td>
<td><img onclick='Delete("/StorageCardSD/Logs/Meldearchiv_20.csv")' src="/Images/Trash.gif"></td>
</tr>

I tried with httpRequest. --> failed I think the redirect is the problem.

LoginTxt = "Login=Administrator&Password=4311&submit=true"

Set XMLHTTP = CreateObject("Microsoft.XMLHTTP")

Adresse = "http://10.100.200.31/"
strLogin = Adresse & "StorageCardSD/Logs?UP=TRUE&FORCEBROWSE"

XMLHTTP.Open "Post", strLogin, False
XMLHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
XMLHTTP.send LoginTxt
XMLHTTP.Open "GET", strLogin, False
XMLHTTP.send

Ropiho
  • 21
  • 1
  • Adresse&"/Logs/Meldearchiv_20.csv " can you pass that to [urlmon](https://stackoverflow.com/a/51234674/6241235)? – QHarr Nov 05 '20 at 17:42
  • It works with the Application.InternetExplorer. With the HTTpRequest it doesnt work ! I dont know how to debug and find the misstake. – Ropiho Nov 07 '20 at 10:55

0 Answers0