+ Reply to Thread
Results 1 to 7 of 7

Excel 2007 : Help to Solve Run-time Error 424 "Object Required"

  1. #1
    D.S.Rama Rao
    Guest

    Help to Solve Run-time Error 424 "Object Required"

    I am getting Run-time Error 424 [Object required] At line No 30 [ Name = "D:\Hindi Music\" & Singer(K, 1) & "\Songs-Solo\" & Songsfile(j, 1) ]and subsequent code starting with line Nos 34,36,44,51,55 and 60 in the below Subroutine.
    Can any expert help me to solve this problem .
    Regards
    D S Rama Rao

    Public Sub PlayMedia()
    Dim t As Double
    Dim S As Integer
    Dim Songsfile As Variant
    Dim Sequence As Variant
    Dim Duration As Variant
    Dim Singers As Variant
    Dim CoSingers As Variant
    Dim Singer As Variant
    Dim FemaleSolo As Variant
    Dim MaleSolo As Variant
    Dim Name As Variant
    Set fso = CreateObject("Scripting.FilesystemObject")
    Songsfile = Range("B1:B26").Value 'Values from Excel worksheet in cell Nos B1 to B26 are Assigned to songsfile
    Sequence = Range("C1:C26").Value 'Values from Excel worksheet in cell Nos C1 to C26 are Assigned to Sequence of songs play
    Duration = Range("D1:D26").Value 'Values from Excel worksheet in cell Nos D1 to D26 are Assigned to Duration of song
    Singers = Range("E1:E26").Value 'Values from Excel worksheet in cell Nos E1 to E26 are Assigned to singers to identify singer
    CoSingers = Range("F1:F26").Value 'Values from Excel worksheet in cell Nos FD1 to F26 are Assigned to Cosingers for ID
    Singer = Range("G1:G14").Value 'Values from Excel worksheet in cell Nos G1 to G14 are Assigned to a group of singers
    FemaleSolo = Range("H1:H37").Value 'Values from Excel worksheet in cell Nos H1 to B37 are Assigned to a Group of female singers
    MaleSolo = Range("I1:I35").Value 'Values from Excel worksheet in cell Nos I1 to B35 are Assigned to Group of male singers
    t = Timer
    S = 0
    For i = 1 To UBound(Sequence)
    For j = 1 To UBound(Songsfile)
    If (Sequence(j, 1) = i) Then
    If IsEmpty(CoSingers(j, 1)) Then
    For K = 1 To UBound(Singer)
    If Singers(j, 1) Is Singer(K, 1) Then 'Identify the first song in sequence
    Name = "D:\Hindi Music\" & Singer(K, 1) & "\Songs-Solo\" & Songsfile(j, 1) 'Append Path of file depending upon singer
    ElseIf Singers(j, 1) Is Not Singer(K, 1) Then
    For L = 1 To UBound(FemaleSolo)
    If Singers(j, 1) Is FemaleSolo(L, 1) Then
    Name = "D:\Hindi Music\ Female Solo\ Songs-Solo\" & Songsfile(j, 1) 'Append Path of file depending upon singer
    Else
    Name = "D:\Hindi Music\ Male Solo\ Songs-Solo\" & Songsfile(j, 1) 'Append Path of file depending upon singer
    End If
    Next L
    End If
    Next K
    ElseIf CoSingers(j, 1) Is Singer(6, 1) Then
    For M = 7 To 8
    If Singers(j, 1) Is Singer(M, 1) Then
    Name = "D:\Hindi Music\" & Singers(j, 1) & "\Songs-Duets With Latha\" & Songsfile(j, 1)' 'Append Path of file as above
    End If
    Next M
    ElseIf CoSingers(j, 1) Is Not Singer(6, 1) Then
    For N = 1 To 8
    If N < 7 Then
    If Singers(j, 1) Is Singer(N, 1) Then
    Name = "D:\Hindi Music\" & Singers(j, 1) & "\Songs-Duets\" & Songsfile(j, 1)' 'Append Path of file as above
    End If
    ElseIf N > 6 Then
    If Singers(j, 1) Is Singer(N, 1) Then
    Name = "D:\Hindi Music\" & Singers(j, 1) & "\Songs-Duets With Others\" & Songsfile(j, 1) 'Append Path of file as above
    End If
    End If
    Next N
    Else
    Name = "D:\Hindi Music\Duets\Songs-Duets\" & Songsfile(j, 1) 'Append Path of file depending upon singer
    End If
    If fso.Fileexists(Pathway & ".mp3") Then ' Append file extension as mp3 and check if file exists
    Sheet1.WindowsMediaPlayer1.URL = Name & ".mp3"
    Sheet1.WindowsMediaPlayer1.Controls.Play
    S = S + Duration(j, 1)
    ElseIf fso.Fileexists(Pathway & ".wav") Then 'Append file extension as wav and check if file exists
    Sheet1.WindowsMediaPlayer1.URL = Name & ".wav"
    Sheet1.WindowsMediaPlayer1.Controls.Play
    S = S + Duration(j, 1) 'Calculate time required to play song
    Else
    MsgBox ("Song Not Found") ' Show massage that file does not exist
    End If
    End If
    Next j
    While Timer < t + S
    DoEvents 'Play song
    Wend
    Next i 'Increment the counter to play next sing in sequence
    End Sub
    Last edited by D.S.Rama Rao; 03-05-2012 at 12:21 AM.

  2. #2
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Help to Solve Run-time Error 424 "Object Required"

    Can you read the forum rules, please, and use code tags around any code you post?

    Your problem here is likely to be because Name is a reserved word in VBA, so you shouldn't use it as a variable name.

  3. #3
    D.S.Rama Rao
    Guest

    Re: Help to Solve Run-time Error 424 "Object Required"

    Dear Andrew-R,

    I have changed the variable Name with Nam.

    However the problem is remaining same.

    In my opinion the problem is due to some other reason

    Hope you will help me as i am not as adept in Visual Basic as i am in Excel.

    Regards;

    D S Rama Rao

  4. #4
    Forum Expert
    Join Date
    07-16-2010
    Location
    Northumberland, UK
    MS-Off Ver
    Excel 2007 (home), Excel 2010 (work)
    Posts
    3,054

    Re: Help to Solve Run-time Error 424 "Object Required"

    Can you please edit your original post and put some code tags in. It would also be helpful if you could post an example workbook.

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Help to Solve Run-time Error 424 "Object Required"

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  6. #6
    D.S.Rama Rao
    Guest

    Re: Help to Solve Run-time Error 424 "Object Required"

    i have solved the problem

    Thank you

    D S Rama Rao

  7. #7
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Help to Solve Run-time Error 424 "Object Required"

    Your post does not comply with Rule 7 of our Forum RULES. Please do not ignore Moderators' or Administrators' requests - note that this includes requests by senior members as well, if you are unclear about their request or instruction then send a private message to them asking for help. Do not post a reply to a thread where a moderator has requested an action that has not been complied with e.g Title change or Code tags...etc

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1