Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 02-09-2023, 10:26 PM
gmayor's Avatar
gmayor gmayor is offline Is it possible to extract mp3's start time and end time by VBA? Windows 10 Is it possible to extract mp3's start time and end time by VBA? Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

You can read the metadata using the code below. However the start time will surely always be 0 and the metadata will give you the length of the mp3. I have left in the code that will read the rest of the metadata should you need it.
Code:
Option Explicit

Sub Test()
'Based on code from
'https://stackoverflow.com/questions/54152307/how-do-i-read-the-metadata-information-from-a-closed-workbook-using-excel-vba
Dim oDetails, sName

    Set oDetails = GetDetails("D:\Sound Data\Pink Floyd - Complete collection\Pink Floyd [1995] - Pulse (Live)\Pink Floyd - 23 - Comfortably Numb.mp3")
    'If oDetails.Exists("Tags") Then Debug.Print oDetails("Tags")
    'If oDetails.Exists("Title") Then Debug.Print oDetails("Title")
    'Debug.Print String(40, "-")
    For Each sName In oDetails
Debug.Print sName & " = " & oDetails(sName)
    Next

End Sub

Function GetDetails(sPath)

    Dim sFolderName, sFileName, oShell, oFolder, oFile, oDetails, i, sName, sValue

    SplitFullPath sPath, sFolderName, sFileName
    Set oShell = CreateObject("Shell.Application")
    Set oFolder = oShell.Namespace(sFolderName)
    Set oFile = oFolder.ParseName(sFileName)
    Set oDetails = CreateObject("Scripting.Dictionary")
    'For i = 0 To 511
        'sName = oFolder.GetDetailsOf(oFolder.Items, i)
        'sValue = oFolder.GetDetailsOf(oFile, i)
        sName = oFolder.GetDetailsOf(oFolder.Items, 27) '27 is the length
        sValue = oFolder.GetDetailsOf(oFile, 27)
        If sName <> "" And sValue <> "" Then oDetails(sName) = sValue
    'Next
    Set GetDetails = oDetails

End Function

Sub SplitFullPath(sPath, sFolderName, sFileName)

    With CreateObject("Scripting.FileSystemObject")
        If Not .FileExists(sPath) Then Exit Sub
        sFolderName = .GetParentFoldername(sPath)
        sFileName = .GetFileName(sPath)
    End With

End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to extract mp3's start time and end time by VBA? Rounding Up or Down depending on Start & End time richardst Excel 4 06-21-2016 06:03 PM
Is it possible to extract mp3's start time and end time by VBA? Start & Finish Date/Time rtuttle Project 9 04-15-2016 06:18 AM
Is it possible to extract mp3's start time and end time by VBA? find shift with start and end time Haha88 Excel 1 10-13-2015 11:30 PM
Is it possible to extract mp3's start time and end time by VBA? Extract data from web - Take a long time edneco Excel Programming 11 06-28-2014 05:54 PM
Increase length of Start time drop down list laguna92651 Outlook 0 07-11-2013 12:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:59 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft