Viene visualizzato l'errore seguente.Errore VBA di Excel 2013
Compile error: The code in this project must be updated for use on 64-bit systems.
codice VBA
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
Dim Ret As Long
'~~> This is where the images will be saved. Change as applicable
Const FolderName As String = "C:\Temp\"
Funziona bene in Excel 2010.
Grazie.
EDIT
errore che ottengo è Ret Variable Not defined
. Ecco il resto del codice.
Sub Sample()
Dim ws As Worksheet
Dim LastRow As Long, i As Long
Dim strPath As String
'~~> Name of the sheet which has the list
Set ws = Sheets("Sheet1")
LastRow = ws.Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRow '<~~ 2 because row 1 has headers
strPath = FolderName & ws.Range("A" & i).Value & ".mp3"
Ret = URLDownloadToFile(0, ws.Range("B" & i).Value, strPath, 0, 0)
If Ret = 0 Then
ws.Range("C" & i).Value = "File successfully downloaded"
Else
ws.Range("C" & i).Value = "Unable to download the file"
End If
Next i
End Sub
Grazie mille, ma avrei dovuto aggiungere anche il resto del codice. L'errore che stavo ottenendo era una correzione, ma ricevo un errore che la variabile 'Ret' non definisce. – Mowgli
Nessun problema. Devi anche convertire la variabile 'Ret' da' Long' a 'LongPtr' in quanto questo è il nuovo tipo di ritorno per la funzione. (se si tratta di una variabile globale, utilizzare 'Pubblico' (o' Privato' solo per quel modulo) invece di 'Dim') – CuberChase
Ciao, scusa se ho appena avuto il tempo. ma ho provato ad aggiungere LongPtr e ho anche provato Public ma non ha funzionato. cosa dovrei fare? grazie – Mowgli