Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi All,
Can we copy a file into local machine from URL. I'm using below macro code to copy the files from source location to destination location.
Is it possible with instead of source local drive location can we place with URL. I tried placing the url in the variable "vImagesLocation" with "http://wvisusmjgwka8/vqdimages/" but didn't got success.
Share your ideas on this. Thanks in advance.
Sub CopyPasteImages
Dim sOriginFolder, sDestinationFolder, sFile, oFSO
Dim iCount, i
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set vLensInspectionImageNames=ActiveDocument.Variables("vLensInspectionImageNames")
Set vImageSourcePath=ActiveDocument.Variables("vImagesLocation")
Set vImageDestinationPath=ActiveDocument.Variables("vImagesDestination")
Set vSuffixImageName=ActiveDocument.Variables("vSuffixImageName")
ArrFields = split(vLensInspectionImageNames.GetContent.String, ",")
ArrFields2= Split(vSuffixImageName.GetContent.String,",")
' iCount = 0
For Each fIndex in ArrFields
sOriginFolder = vImageSourcePath.GetContent.string&fIndex
sDestinationFolder = vImageDestinationPath.GetContent.string&ArrFields2(i)&"-"&fIndex
if oFSO.fileExists(sOriginFolder) then
' iCount = iCount + 1
oFSO.CopyFile sOriginFolder, sDestinationFolder
end if
' If iCount >=500 then Exit Sub
Next
End Sub
you can use wget for win and call it with execiute. Following macro i used, i think i found it in this community long time ago. Want you call it from the UI or from the skript? Much faster is robocopy if you can adress a unc and have a goot filter statement, robocopy has lots of options.
sub downloadaktuell
strFileURL = "http://www.dwd.de/bvbw/generator/DWDWWW/Content/Oeffentlichkeit/KU/KU2/KU21/klimadaten/german/downlo..."
strHDLocation = "C:\QlikView\Sonstiges\Wetter\aktuell.zip"
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
end sub
I'm not a huge networking expert, but I think you can do it the following way:
1. Create a shared folder on your machine and give it a name.
2. Refer to it using the UNC convention:
\\<machine_name>\<share_name>
For example:
Notice that vqdimages is not just a folder, but a "Share name", the way you created it.
cheers,
Oleg Troyansky
Check out my book QlikView Your Business - now available to pre-order on Amazon!
you can use wget for win and call it with execiute. Following macro i used, i think i found it in this community long time ago. Want you call it from the UI or from the skript? Much faster is robocopy if you can adress a unc and have a goot filter statement, robocopy has lots of options.
sub downloadaktuell
strFileURL = "http://www.dwd.de/bvbw/generator/DWDWWW/Content/Oeffentlichkeit/KU/KU2/KU21/klimadaten/german/downlo..."
strHDLocation = "C:\QlikView\Sonstiges\Wetter\aktuell.zip"
Set objXMLHTTP = CreateObject("MSXML2.XMLHTTP")
objXMLHTTP.open "GET", strFileURL, false
objXMLHTTP.send()
If objXMLHTTP.Status = 200 Then
Set objADOStream = CreateObject("ADODB.Stream")
objADOStream.Open
objADOStream.Type = 1
objADOStream.Write objXMLHTTP.ResponseBody
objADOStream.Position = 0
Set objFSO = Createobject("Scripting.FileSystemObject")
If objFSO.Fileexists(strHDLocation) Then objFSO.DeleteFile strHDLocation
Set objFSO = Nothing
objADOStream.SaveToFile strHDLocation
objADOStream.Close
Set objADOStream = Nothing
End if
Set objXMLHTTP = Nothing
end sub
Jonas, this is what i'm looking for. Thank you for sharing your ideas on this.
Hi Jonas,
I when I try to execute the macro , I am getting error objXMLHTTP.open "GET", strFileURL, false as PErmissions denied. Can you please help me how to rectify this.
Hi,
have you set the security lvl of the macro to allow external file actions? (under the Test button)
Hi Jonas,
It is working for me after I checked "Can Execute External Programs " under settings in Script editor.
Thanks for the response. I posted my application in Copy Multiple Files from SharePoint to Local
Regards,
Kamakshi Suram