Retrieving Song Length

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:

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,215,045
Messages
6,122,836
Members
449,096
Latest member
Erald

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