+ Reply to Thread
Results 1 to 3 of 3

Runtime Error - Object Required

  1. #1
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Runtime Error - Object Required

    I am trying to play a sound file according to what is entered within a cell. The code I have is:

    If Target.Cells.Value = 0 Then
    Call PlaySoundFile("C:\Users\Number1.wav")
    End If
    This code works fine if I put it at the beginning of the worksheet_change on the sheet, however, I have tried to move the calling of the sounds into a separate sub so I can use it in other ways, but get an object required runtime error.

    Any ideas why it works ok within worksheet_change and why it doesn't in a separate sub that is just getting called from worksheet_change?

    Also, any ideas on how to change this so I can get it to work?

    Thanks in advance

  2. #2
    Forum Contributor
    Join Date
    06-22-2011
    Location
    somerset
    MS-Off Ver
    365
    Posts
    330

    Re: Runtime Error - Object Required

    what is the sub for playsoundfile?
    Please Login or Register  to view this content.
    Sub Reputation()
    Dim Problem as Variant
    Dim Reputation as Integer
    For Each Problem in Forum.Threads
        If Problem.Title = "*[Solved]*" and Solver.Name = "Leon V (AW)" Then Reputation = Reputation + 1
    Next Problem
    End Sub

  3. #3
    Registered User
    Join Date
    01-20-2014
    Location
    Scotland
    MS-Off Ver
    Excel 2003
    Posts
    59

    Re: Runtime Error - Object Required

    The sub for the playsoundfile is:

    Sub PlaySoundFile(SoundFilePath As String)

    Dim Ret As Long
    Const SND_ASYNC = &H1
    Const SND_NODEFAULT = &H2
    Const SND_FILENAME = &H20000


    Ret = PlaySoundA(SoundFilePath, 0&, SND_ASYNC Or SND_NODEFAULT Or SND_FILENAME)

    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Runtime error 424 Object required
    By aman1234 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-10-2013, 09:37 AM
  2. [SOLVED] Runtime error 424 Object Required - HELP ME
    By joh46k in forum Excel Programming / VBA / Macros
    Replies: 16
    Last Post: 05-09-2013, 03:26 AM
  3. Runtime Error '424' - Object Required
    By ffffloyd in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-02-2011, 09:52 PM
  4. Runtime Error # 424 - Object Required
    By ebin charles in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-16-2010, 12:47 PM
  5. Runtime Error 424 - Object Required
    By teaker in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 06-09-2009, 04:04 PM

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