MagneticPotato
New Member
- Joined
- Nov 29, 2017
- Messages
- 11
In A col I have the name of the song and I am attempting to use a loop to add the song length for each song. If I replace the Namespace(Directory) with Namespace("path in quotes") and do the same for o.GetDetailsOf(o.Items.Item(f), 27), it works fine, but that won't loop through. I get an Object variable or with block variable not set error. Any Ideas?
Code:
Sub AddSongs()Dim Directory As String
Dim r As Long
Dim f As String
Dim z As Integer
Dim o As Object
Dim filling As String
Dim total As Integer
Application.ScreenUpdating = False
Directory = Sheets("H").Range("B6")
r = 1
f = Dir(Directory & "*.mp3", vbReadOnly + vbHidden + vbSystem)
Sheets("Log").Range("j2") = x
Do While f <> ""
r = Sheets("Log").Range("j1")
Sheets("Log").Range("j2") = Directory & f
If Sheets("Log").Range("j3") = 0 Then
Cells(r, 1) = f
Set o = CreateObject("shell.application").Namespace(Directory)
filling = o.GetDetailsOf(o.Items.Item(f), 27)
total = total + (Mid(filling, 2, 1)) * 3600
total = total + (Mid(filling, 4, 1)) * 600
total = total + (Mid(filling, 5, 1)) * 60
total = total + (Mid(filling, 7, 1)) * 10
total = total + (Mid(filling, 8, 1)) * 1
Cells(r, 1).Offset(0, 1) = total
f = Dir()
Else
f = Dir()
End If
Loop
Application.ScreenUpdating = True
End Sub
Last edited: