I've written a VBScript script for file download. I use this line to build the download URL:
strURL = DownloadDest & pdfs(n)
But when I run the script, strURL gets just the DownloadDest value without pdfs(n). Why doesn't string concatenation work?
Complete script:
dim pdfs(9)
pdfs(1) = "Karusel_PF_Promo18_food.pdf"
pdfs(2) = "Karusel_ZCHF_promo18_food.pdf"
pdfs(3) = "Karusel_YF_promo18_food.pdf"
pdfs(4) = "karusel_Moscow_promo18_food.pdf"
pdfs(5) = "Karusel_SVF_promo18_food.pdf"
pdfs(6) = "Karusel_VVF_Promo18_food.pdf"
pdfs(7) = "Karusel_SZF_Promo18_food.pdf"
pdfs(8) = "Karusel_SOCHI_promo18_food.pdf"
pdfs(9) = "Karusel_VLGRD_promo18_food.pdf"
Const scriptVer = "1.0"
const DownloadDest = "http://karusel.ru/manager/img/PDF/"
Const LocalFile = "C:\Users\syurchen\Desktop\"
Const DownloadType = "binary"
dim strURL
dim localfile2
function getit(n)
dim xmlhttp
set xmlhttp = createobject("MSXML2.XMLHTTP.3.0")
strURL = DownloadDest & pdfs(n)
localfile2 = LocalFile & pdfs(n)
msgbox "Download-URL: " & strURL
xmlhttp.Open "GET", strURL, false
xmlhttp.Send
Wscript.Echo "Download-Status: " & xmlhttp.Status & " " & xmlhttp.statusText
If xmlhttp.Status = 200 Then
Dim objStream
set objStream = CreateObject("ADODB.Stream")
objStream.Type = 1 'adTypeBinary
objStream.Open
objStream.Write xmlhttp.responseBody
objStream.SaveToFile localFile2
objStream.Close
set objStream = Nothing
End If
set xmlhttp = Nothing
End function
For Each n In pdfs
getit(n)
Next