Morning all,
I have the following routine in an Excel module. This copies a Sharepoint file to a specific folder:-
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" ( _
ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Sub DownloadFileFromWeb()
Dim i As Integer
Dim strSavePath As String
Dim returnValue As Long
Const strUrl As String = "https://filename.xlsx"
strSavePath = "H:\filename.xlsx"
returnValue = URLDownloadToFile(0, strUrl, strSavePath, 0, 0)
End sub
I would llke to transfer this code to a VBS Script. In the past, I have created an Excel file with the VBA included and then triggered the macro via VBS Script.
I've tried implementing the code into VBS Script but get an error on the PRIVATE DECLARE FUNCTION line. To be honest, I'm not sure if you can declare functions, or whether I also need to reference the Excel object first.
Many thanks in advance.
I have the following routine in an Excel module. This copies a Sharepoint file to a specific folder:-
Option Explicit
Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" ( _
ByVal pCaller As Long, ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Sub DownloadFileFromWeb()
Dim i As Integer
Dim strSavePath As String
Dim returnValue As Long
Const strUrl As String = "https://filename.xlsx"
strSavePath = "H:\filename.xlsx"
returnValue = URLDownloadToFile(0, strUrl, strSavePath, 0, 0)
End sub
I would llke to transfer this code to a VBS Script. In the past, I have created an Excel file with the VBA included and then triggered the macro via VBS Script.
I've tried implementing the code into VBS Script but get an error on the PRIVATE DECLARE FUNCTION line. To be honest, I'm not sure if you can declare functions, or whether I also need to reference the Excel object first.
Many thanks in advance.