次のエラーが発生しています。Excel 2013 VBAエラー
Compile error: The code in this project must be updated for use on 64-bit systems.
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\"
これは、Excel 2010で
感謝を正常に動作します。私が手
EDIT
エラーがRet Variable Not defined
です。残りのコードは次のとおりです。
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
ありがとうございますが、残りのコードも追加する必要があります。前回のエラーは修正されましたが、 'Ret'変数が定義されていないというエラーが発生しています。 – Mowgli
probsはありません。 'Ret'変数を' Long'から 'LongPtr'に変換する必要があります。これは、関数の新しい戻り値の型であるためです。 (グローバル変数の場合は、 'Dim'の代わりに' Public'(またはそのモジュールだけに 'Private')を使用してください) – CuberChase
こんにちは、すみません。私はLongPtrを追加しようとしましたが、Publicを試みましたが、うまくいきませんでした。私は何をすべきか?ありがとう – Mowgli