我已經寫了一個用於文件下載的VBScript腳本。我用這條線來構建下載網址:爲什麼我的VBScript字符串連接不起作用?
strURL = DownloadDest & pdfs(n)
但是當我運行該腳本,strURL
只是取DownloadDest
值而不pdfs(n)
。爲什麼字符串連接不工作?
完整的腳本:
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
我冒昧地改寫你的問題,使問題描述清楚其他讀者。希望你不介意。 – Helen 2014-09-05 11:09:16