上記の問題の解決策をリポジトリで検索しようとしましたが、私の VBA のスキルは初歩的であり、答えがわかりません。ガイダンスをいただければ幸いです。
以下のコードを実行すると、次の行でエラーが発生します。
PartNumber = Range("E" & myrow).Value
コードは実行時エラー '1004': メソッド 'Range of object'_Global が失敗しました。
Dim objDrv As Object
Dim strMsg As String
For Each objDrv In CreateObject("Scripting.FileSystemObject").drives
Select Case objDrv.DriveType
Case 0: strMsg = strMsg & vbNewLine & objDrv.driveletter & ": Unknown"
Case 1: strMsg = strMsg & vbNewLine & objDrv.driveletter & ": Removable Drive"
Case 2: strMsg = strMsg & vbNewLine & objDrv.driveletter & ": Hard Disk Drive"
Case 3: strMsg = strMsg & vbNewLine & objDrv.driveletter & ": Network Drive"
'Case 4: strMsg = strMsg & vbNewLine & objDrv.driveletter & ": CDROM Drive"
Case 5: strMsg = strMsg & vbNewLine & objDrv.driveletter & ": RAM Disk Drive"
End Select
Next
Set objDrv = Nothing
'MsgBox strMsg, vbInformation
Dim sdcard As String
sdcard = InputBox( _
"Confirm which drive you wnat to create the romdata directory in." & vbNewLine & vbNewLine & "Drives Found:" _
& strMsg & vbNewLine, _
"Choose SD Card Letter.", _
"Type your file name here")
If Len(sdcard) = 1 Then
MsgBox "You have selcted the " & sdcard & " drive."
ElseIf Len(sdcard) >= 2 Then
MsgBox " Too many characters"
ElseIf Len(sdcard) <= 0 Then
End If
Dim myLoop As Integer
For myLoop = 7 To 9000
If Len(Range("I" & myLoop).Value) > 0 Then
Dim aTemp As String
Dim bTemp As String
Dim dTemp As String
Dim eTemp As String
Dim subdir As String
Dim PartNumber As String
Dim otemp As String
Dim ptemp As String
aTemp = sdcard & Chr(58) & "\romdata\"
a1temp = sdcard & Chr(58) & "\romdata"
bTemp = strMsg
PartNumber = Range("E" & myrow).Value
otemp = PartNumber & ".fwu"
ptemp = "\" & PartNumber
dTemp = ActiveWorkbook.pATH
eTemp = "\Firmware files"
subdir = "\Firmware Files\" & PartNumber & "\" & otemp
MsgBox "The full path to this file is " & dTemp & "\" & PartNumber
If dir(dTemp & subdir) = "" Then
MsgBox "The file you have selected, (" & PartNumber & ") will not be copied." & vbNewLine & _
"Please check the file is suitable for uploading to the device using an SD card." & vbNewLine & _
"(It should have a .fwu extension.)"
Exit Sub
End If
MsgBox "The file " & otemp & " is being copied to " & aTemp
If Len(dir(aTemp, vbDirectory)) = 0 Then
MkDir a1temp
End If
FileCopy dTemp & subdir, aTemp & otemp