Alaska Software Inc. - Download a file from a URL with ActiveX
Username: Password:
AuthorTopic: Download a file from a URL with ActiveX
César Calvo Download a file from a URL with ActiveX
on Fri, 30 Nov 2018 21:46:45 +0100
Hello, for do this if I try with source below it not download the file:

PROCEDURE DESCARGAR()
LOCAL myURL, WinHttpReq, oStream

   myURL := "http://www.tarifec.es/priv/excel/271/3M 01-02-2018.xls"

   WinHttpReq = CreateObject("Microsoft.XMLHTTP")
   WinHttpReq:Open("GET", myURL, False) //, "username", "password"
   WinHttpReq:send

   myURL := WinHttpReq:responseBody

   If WinHttpReq:Status = 200
      oStream := CreateObject("ADODB.Stream")
      oStream:Open
      oStream:Type = 1
      //oStream:Write(WinHttpReq:responseBody)
      oStream:SaveToFile('C:\3M 01-02-2018.xls', 2) //1 = no overwrite, 2 = 
overwrite
      oStream:Close
   EndIf

RETURN

And if I quit the  in //oStream:Write(WinHttpReq:responseBody) then this 
error:

oError:canDefault   : Y
oError:canRetry     : N
oError:canSubstitute: Y
oError:cargo        : NIL
oError:description  : Argumentos incorrectos, fuera del intervalo permitido 
o en conflicto con otros. //// Incorrect arguments, outside the allowed 
range or in conflict with others.
oError:filename     : NIL
oError:genCode      : NIL
oError:operation    : Write
oError:osCode       :          -2146825287
oError:severity     :          2
oError:subCode      :       6500
oError:subSystem    : Automation
oError:thread       :          1
oError:tries        : NIL
------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------

Called from DESCARGAR(145)
Called from TARIFEC:AJUSTAR(124)
Called from (B)TARIFEC:INIT(58)
Called from DSPUSHBUTTON:HANDLEEVENT(1347)
Called from APPEXEC(239)
Called from MAIN(55)

Could somebody how do it?

Thanks in advance.
César Calvo.
César Calvo Re: Download a file from a URL with ActiveX
on Fri, 30 Nov 2018 23:22:42 +0100
I see if I change from unit C to Unit D, it download a fie but with an error 
xls file that I attachment.

oStream:SaveToFile('D:\3M 01-02-2018.xls', 2) //1 = no overwrite, 2 = 
overwrite

"César Calvo"  escribió en el mensaje de 
noticias:6d82817f$54676c70$cfe1@news.alaska-software.com...

Hello, for do this if I try with source below it not download the file:

PROCEDURE DESCARGAR()
LOCAL myURL, WinHttpReq, oStream

   myURL := "http://www.tarifec.es/priv/excel/271/3M 01-02-2018.xls"

   WinHttpReq = CreateObject("Microsoft.XMLHTTP")
   WinHttpReq:Open("GET", myURL, False) //, "username", "password"
   WinHttpReq:send

   myURL := WinHttpReq:responseBody

   If WinHttpReq:Status = 200
      oStream := CreateObject("ADODB.Stream")
      oStream:Open
      oStream:Type = 1
      //oStream:Write(WinHttpReq:responseBody)
      oStream:SaveToFile('C:\3M 01-02-2018.xls', 2) //1 = no overwrite, 2 =
overwrite
      oStream:Close
   EndIf

RETURN

And if I quit the  in //oStream:Write(WinHttpReq:responseBody) then this
error:

oError:canDefault   : Y
oError:canRetry     : N
oError:canSubstitute: Y
oError:cargo        : NIL
oError:description  : Argumentos incorrectos, fuera del intervalo permitido
o en conflicto con otros. //// Incorrect arguments, outside the allowed
range or in conflict with others.
oError:filename     : NIL
oError:genCode      : NIL
oError:operation    : Write
oError:osCode       :          -2146825287
oError:severity     :          2
oError:subCode      :       6500
oError:subSystem    : Automation
oError:thread       :          1
oError:tries        : NIL
------------------------------------------------------------------------------
CALLSTACK:
------------------------------------------------------------------------------

Called from DESCARGAR(145)
Called from TARIFEC:AJUSTAR(124)
Called from (B)TARIFEC:INIT(58)
Called from DSPUSHBUTTON:HANDLEEVENT(1347)
Called from APPEXEC(239)
Called from MAIN(55)

Could somebody how do it?

Thanks in advance.
César Calvo.


3M 01-02-2018.xls