VBS Script

LEXCERM

Active Member
Joined
Jun 26, 2004
Messages
320
Office Version
  1. 365
Platform
  1. Windows
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. :)
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,226,125
Messages
6,189,128
Members
453,524
Latest member
AshJames

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top