+ Reply to Thread
Results 1 to 70 of 70

Play sound as embed object in worksheet

  1. #1
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Play sound as embed object in worksheet

    Hi,

    i added *.wav to excel file and want to play when condition is met in cell A1.

    It is possible directly use object from Excel?
    Can you help with code?Screenshot_12.png

    Best,
    Jacek

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    This macro plays the Windows sound TADA, when a cell in the noted range changes :

    Please Login or Register  to view this content.
    You should be able to edit this line for your purpose of cell A1 :

    Please Login or Register  to view this content.

    Since I don't know what value you are looking for in A1, here is a suggestion for the code :

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    thank you very much!

    Problem is that i want to add my own sound into workbook.

    Best,
    Jacek

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    Change the path of sound file as shown in the macro. Just make certain it is a WAV file.

    PlaySoundA "C:\Users\MyComputer\Desktop\ThisIsMyWavFile.wav", 0&, &H20001


    PlaySoundA "C:\WavFile\ThisIsMyWavFile.wav", 0&, &H20001


    PlaySoundA "D:\SoundsForMyExcelWorkbooks\ThisIsMyWavFile.wav", 0&, &H20001

  5. #5
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi Logit,

    thank you.

    But you are using files which you have on disc. I want to add file directly to workbook and use it in every computer.

    So somehow save embedded file into disc and read from it.

    Best,
    Jacek

  6. #6
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Ok Guys,

    i found very strange code to achieve this.

    This is converting wav file to Long to and read this directly in workbook.

    Code is from here:
    http://www.vbaexpress.com/forum/show...workbook-opens

    Best,
    Jacek
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    I fixed the issues.

    I am attaching maybe can be useful for you friends.

    Best wishes,
    Jacek
    Attached Files Attached Files

  8. #8
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Play sound as embed object in worksheet

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  9. #9
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Not yet,

    maybe other people have better solution for this.
    Code is very big and not nice (using embedde object to play sound) so i am still open to other answers.

    Jacek

  10. #10
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Play sound as embed object in worksheet

    Then saying this was VERY misleading:

    I fixed the issues.

    I am attaching maybe can be useful for you friends.

  11. #11
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Sorry,

    but i fixed the issues.

    But i am always trying to get the best possible solution. Here - i am not sure, maybe there is an other way to do this.

    Best,
    Jacek

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    jaryszek

    Let me know if the sound file in the attached plays for you. Thanks.
    Attached Files Attached Files

  13. #13
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    hi Logit,

    it is working like a charm.
    Question is this Precious.wav is windows sound?
    It is not added by you?

    Jacek

  14. #14
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    That wav file is something I found on the Internet to go along with the image. So Excel takes the wav file you link to by path and makes it a part of the workbook.
    No need to carry the wav file and post it into a Temp folder or such.

    My personal preference though, were there to be more than a few wav files, is to store them on the users computer in a temp folder. Just for safety sake. I've found
    Excel / VBA tends to do what it wants at the most inopportune times.

    Kinda like having a wife.

  15. #15
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    hi Logit,

    wow
    thank you very much.
    How this code is working ?

    Call sndPlaySound32(ThisWorkbook.Path & "\My_Precious.wav", 1)
    That wav file is something I found on the Internet to go along with the image.
    How this is working? image with wav? can i add for my image my own wavs?
    And how to have them in seperate folder?

    this is looking wav on disc but there is no file on disc? When it is beeing downloaded?

    and where this image is attached to sound?
    I am not understanding this but seems awesome!

    please help.

    p.s i have wife and she is doing what she wants to

    Best,
    Jacek

  16. #16
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    The image is not involved in playing the wav file.

    This macro is in the ThisWorkbook module :

    Please Login or Register  to view this content.
    The wav file is played automatically when the workbook is opened. You can also play the wav file by clicking on the button.
    And again, the sound will play with or without the image.

    As I indicated in my last post, nothing is being downloaded when you open the workbook. The wav file is made part of the workbook via Excel. When you send the workbook
    to someone the wav file goes along with the workbook. Again ... nothing is downloaded.

    Now, having said that ... if there were a number of wav files to be made a part of the workbook ... my personal preference would be to send those wav files along with the
    workbook (if I were sending the workbook to someone else). I would make provisions for the wav files to be placed somewhere on the other person's computer and have the
    macro written in such a way for the macro code to reference the wav file/s where they are located on the other person's computer.

  17. #17
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    thank you Logit,

    The wav file is made part of the workbook via Excel
    ok so how can i create wav part as part of Excel?

    And second issue,

    my personal preference would be to send those wav files along with the
    workbook (if I were sending the workbook to someone else).
    So user would have to add these files manually for specific folder yes?

    Best,
    Jacek

  18. #18
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    ok so how can i create wav part as part of Excel?
    Create a workbook with a path to a wav file. Like I did with the example I sent you.
    Make certain the wav file isn't a part of the Windows operating system. Find something unique
    from the internet.

    When you send the workbook (you can send the example to me) the sound should play, just as it did in my example.


    So user would have to add these files manually for specific folder yes?
    You could do it that way BUT ... as the programmer, you have the responsibility to include in your coding a means
    for the project to create the folder with the wav files in it.

  19. #19
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi Logit,

    thank you.

    Create a workbook with a path to a wav file
    Ok, are you attaching embedded object to workbook and providing path to file?

    Best,
    Jacek

  20. #20
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    No .. I only provided a path in the macro to the wav file on my computer.

    What sound do you hear when you open my workbook ?
    Last edited by Logit; 04-19-2019 at 03:54 PM.

  21. #21
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    I believe something else is occurring here with the workbook I sent you (posted) as it probably doesn't play the sound on your side. I was presuming it did play the wav file as you were
    indicating it did. ????

    In any case, your questions prompted me to do some searching for an answer to insure a wav file could be played in a workbook without having to include the wav file itself.

    I found this resource which works very well : http://www.vbaexpress.com/forum/show...workbook-opens

    If you follow Leith's instructions (very easily done), your workbook will end up with a sheet named "Byte Data" where the wav file (which you have selected from your own computer) is converted and stored.
    His example allows for the wav file to play when the workbook is opened. I edited the code to allow for a manual play of the wav file as well.

    Please Login or Register  to view this content.

    Please Login or Register  to view this content.

    And this macro connected to a button that allows for manual play :

    Please Login or Register  to view this content.


    Both my original workbook and this one were done as an experiment ... for fun. Curiosity more than anything. I still hold to my other recommendation
    if the purpose is to have more than one wav file or if the project were something more than a "toy", I would provide for the wav files to be copied to
    the users' computer and referenced by file path in the coding.
    Attached Files Attached Files

  22. #22
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    hi logit,

    thank you very much. Awesome help from your side!

    Wow this code which is changing wav to bytes and numbers - magic!

    I created solution based on sample to have more than 1 wav file in workbook as embedded objects.
    When workbook is opening i am creating temporary folder and when workbook is closed - i am dleeting folder with wavs.

    And i am using playsound function to run files from specific temporary folder.

    Closing the topic.

    Thank you once again for help and support,
    Jacek
    Attached Files Attached Files

  23. #23
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    I am unable to get a sound to play with your last posted workbook. ????

  24. #24
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi logit,

    i modified file.

    Please try buttons on sheet "Play".

    On workbook open wav files should be saved into Temp folder (the same path as workbook).
    And path ti these files are public so after clicking buttons you should hear audio.

    Let me know how it is working for you.

    Best,
    Jacek
    Attached Files Attached Files

  25. #25
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    Sorry ... no success. I've researched numerous websites for "play embedded wav file" but nothing so far works.

    Of course, if I double click on the embedded file icon itself, the wav file plays.

    ???

  26. #26
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi Logit,

    what error do you have?

    If fnBell path is declared on workook open and temp file created? i saw that i have error here :

    Please Login or Register  to view this content.
    I tested on second laptop and this is working for me.

    Please go to "PlaySoundButtons" module and paste this code:

    Please Login or Register  to view this content.
    and you should have as final code:

    Please Login or Register  to view this content.
    Best,
    Jacek

  27. #27
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    I'm not seeing a TEMP folder created. I've checked my DOWNLOAD folder, the C Drive and several other locations.

    This part causes my system issues because I'm running 64 bit O/S and 32 bit Excel :

    Please Login or Register  to view this content.
    To get around that error, you can change it to :

    Please Login or Register  to view this content.
    I also receive a "Sub or Function Not Defined" on this :

    Please Login or Register  to view this content.
    I have been unable to locate a definition of "mciExecute".

    What references are you using in the VBE \ Tools \ References dropdown ?

  28. #28
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi Logit. I will investigate issues after Easter and let you know. In meantime can anybody test on Excel 64 bit if this is working for him? Best wishes Jacek

  29. #29
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    The image is just like a button, you click it and it runs the macro, how difficult is that to understand?
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  30. #30
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    And if you want to play the sound via a Command Button and not have the windows player appear on screen ?

    How difficult is that to understand ?

  31. #31
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi Guys,

    The image is just like a button, you click it and it runs the macro, how difficult is that to understand?
    ok so this is working for you Keebellah ? Good.

    Ok Logit,

    first of all , this command is not working for you ?

    Please Login or Register  to view this content.
    it should create folder name :

    Attachment 621009

    What error do you have ? If this is not working, just please create this folder manually.

    When i tried to use your code logit:

    Please Login or Register  to view this content.
    i have also issue that function is undefined.

    Attachment 621010

    the code for playing music is from here:

    https://books.google.pl/books?id=46t...page&q&f=false

    i am very interesting why this is not working for you. We have to fix this together ;-)

    Best,
    Jacek

  32. #32
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Logit,

    try to use:

    Please Login or Register  to view this content.
    with function:

    Please Login or Register  to view this content.
    it is working for you?

    Jacek

  33. #33
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    Are you sure the wav file exists in the TEMP folder?

  34. #34
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Keebellah,

    for me yes, on workbook open wav files are saved into temp folder.
    It is working for you?

    If not please help to identify where issue occurs.

    Best,
    Jacek

  35. #35
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    This will never work
    Please Login or Register  to view this content.

  36. #36
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    This does work
    Please Login or Register  to view this content.

  37. #37
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Ok,

    i am attaching the newest code. Please refer to it.
    You are referring to old code which is not used.

    In module "PlaySoundButtons" we have:

    Please Login or Register  to view this content.
    In module mMain i have function declared:

    Please Login or Register  to view this content.
    On workbook open i have :
    Please Login or Register  to view this content.
    in attachment please find sample workbook and let me know it is working for you.
    Attached Files Attached Files

  38. #38
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    This sample you posted works perfectly here

  39. #39
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Thank you very much,

    waiting for Logit and US time

    Best,
    Jacek

  40. #40
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    Why're you waiting for them?
    Here's your file back with the three buttons, works here
    Attached Files Attached Files

  41. #41
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .


    jaryszek:

    The code is creating the folder in my Downloads folder and naming it: Timer_temp_wav_files

    However, it is failing to copy the WAV files into the folder.

    The error msg is :

    Run-time error '1004'
    Method'OLEObjects' of object'_Worksheet' failed
    The highlighted line in Workbook_Open macro is :

    SaveWAVOLEAs WavWb.OLEObjects(BellName), fnBell

  42. #42
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Why're you waiting for them?
    Because i would like to have this working for all users.


    The code is creating the folder in my Downloads folder and naming it: Timer_temp_wav_files
    this is correct.

    Run-time error '1004'
    Method'OLEObjects' of object'_Worksheet' failed
    try solution from here:
    https://www.excelforum.com/excel-pro...et-failed.html

    I changed a code here:

    Please Login or Register  to view this content.
    Let me know it is working for you. If not i think we should create new topic for this.

    Best,
    Jacek
    Attached Files Attached Files

  43. #43
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    Jacek ...

    Sorry ... stilll the same.

    Makes the directory but doesn't copy the wav file. Same error message.

  44. #44
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Ok can you please create seperate topic?

    Working for me and Keebellah and not working for you.

    Best,
    Jacek

  45. #45
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    That's fine. Thanks.

    Best wishes.

  46. #46
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Logit,

    this is not fine, we should create topic to have this working.

    Best,
    Jacek

  47. #47
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    The worksheet failed is probably the old code where SaveEmbedded is stated. there it's looking for a sheet named YesMaster that throws indeed that error
    The new folder is indeed a sub-folder of where this excel file is saved, in your case the downloads because you downloaded it there and the was are copied correctly and also removed when you close the file.
    No problems here, it also copies three wav files with the names as there are on the sheet in the TEMP folder and these are also removed when closing, so all in all it works.
    Just open the file wait and then press one of the buttons. Iadded a debug.print to to sheow where it's getting the file
    Attached Files Attached Files

  48. #48
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Play sound as embed object in worksheet

    Ok can you please create seperate topic?
    Logit,

    this is not fine, we should create topic to have this working.
    Jaryszek - if you want the issue solving, then keep this thread open. There is no need for a new thread, and it certainly is NOT Logit's job to pursue it. If you wish to pursue it here and Logit is happy to answer questions, that's fine, but if not, you will have to let the matter drop. Please do not try to put pressure on other members in this way. Thanks.
    Last edited by AliGW; 04-23-2019 at 02:40 AM.

  49. #49
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Thank you Kebellah,

    working like a charm, thank you for getting involved.

    Ali,

    nobody is putting pressure on anything
    Relax and chill.
    Better please tell it is working for you.

    Topic is solved, if something is not working for somebody - it is not fine to keep with error but of course - i am not forcing to do anything - it is user choice

    Best Wishes,
    Jacek

  50. #50
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    @Jacek: you should read carefully how you formulated your questions and YES it does in a way FORCE and out pressure on others, I agree with Ali, but ... glad it's working

  51. #51
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    sorry this is my english i am improving all the time but sometimes you can misunderstand me.

    Yeeah the most important thing is that this is working. ;-)

    Best Wishes,
    Jacek

  52. #52
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,333

    Re: Play sound as embed object in worksheet

    Relax and chill.
    Please don't make comments like this. Thanks.

  53. #53
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Play sound as embed object in worksheet

    Same as Logit this wasn't working for me.

    Edited example file from Keebellah in Post#47 to make it work for me too.

    @ Logit

    Try this example file to see if it's working for you now too.
    Attached Files Attached Files
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  54. #54
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    bakerman2 thank you!!!

    you are awesome man!

    Ok i see that you changed "_" for "." - why is that?

    Please Login or Register  to view this content.
    Jacek

  55. #55
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Play sound as embed object in worksheet

    The problem for me seemed to be that the Objects names weren't recognised with a dot in it.

    I replaced the dot in the objects names with an undescore, edited the Const names to the new names and added the Replace to change the undescore back to dot to create the correct filename.

    We now have to wait for Logit's response to see if that's a solution for him too and the file works for every user.

  56. #56
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Thank you very much,

    maybe you have found the issue!

    Best wishes,
    Jacek

  57. #57
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    6,986

    Re: Play sound as embed object in worksheet

    .
    bakerman2 ... once again you have come through with a solution !

    jaryszek ... bakerman2's editing made the difference. Everything works 100% here now.


    Kudos to you and everyone else involved !

    Cheers !!!

    (ps: Apologies for not responding sooner. I haven't been receiving then notification emails for months now.)

  58. #58
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi Logit,

    glad that we helped

    Best,
    Jacek

  59. #59
    Registered User
    Join Date
    08-24-2019
    Location
    Livorno, Italy
    MS-Off Ver
    2010
    Posts
    3

    Re: Play sound as embed object in worksheet

    VERY GOOD! But .... When running in 64-bit versions of Office, Declare statements must include the PtrSafe keyword. The PtrSafe keyword asserts that a Declare statement is safe to run in 64-bit development environments.

  60. #60
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    hi,

    without it will not work?

    Jacek

  61. #61
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    That is just to ensure compatibility and make it functional in both versions

  62. #62
    Registered User
    Join Date
    08-24-2019
    Location
    Livorno, Italy
    MS-Off Ver
    2010
    Posts
    3

    Re: Play sound with embedded WAV object in worksheet

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    With previous coding Windows Media Player start playing correctly in a different window, but Windows focus does not come back to EXCEL,
    even if I force it to stay at top, and the macro pauses: I have to click somewhere on EXCEL window to resume the macro activity.
    Any way to bring focus back to EXCEL?
    Thanks for your help, I am just beginning to use VBA macros.
    (WINDOWS 10 64, Office 2010 64)
    Last edited by Labronico; 08-26-2019 at 03:59 AM.

  63. #63
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    Sorry cannot delete this but my answer is for another post
    Buona Notte

  64. #64
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    BTW this is corrected so that it's 32 and 64 bit compatible
    But still there is no media player here so I suggest you start your own post with your question
    Attached Files Attached Files

  65. #65
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    Hi,

    thank you,
    you added this "PtrSafe" everywhere into every function? Or there is more changes?

    Best,
    Jacek

  66. #66
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    No, just where it's required in the Public Declare Function ...
    That's where it belongs
    You should Google for this and you'll see what it does and how to use

  67. #67
    Forum Contributor
    Join Date
    01-16-2014
    Location
    Poland
    MS-Off Ver
    Excel 2016-365
    Posts
    2,940

    Re: Play sound as embed object in worksheet

    thank you!

    Jacek

  68. #68
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet

    Nie ma za co
    (Google translate )

  69. #69
    Registered User
    Join Date
    08-24-2019
    Location
    Livorno, Italy
    MS-Off Ver
    2010
    Posts
    3

    Re: Play sound with embedded WAV object in worksheet

    [CODE][Sleep 2000 ' control the time of playing/CODE]
    [CODE][Shell "taskkill /T /F /IM wmplayer.exe" 'kill the active Windows Media Player instance /CODE]
    I reply to my own post.
    I solved adding the previous two staments, having forced EXCEL TO STAY ON TOP (as suggested elsewere)

  70. #70
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: Play sound as embed object in worksheet


+ 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. Embed a mp3 file into worksheet and write a code on userform to play it
    By pinaki953 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-24-2016, 04:48 PM
  2. [SOLVED] Play Sound When Conditions are Met
    By Chris632 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-31-2013, 04:14 AM
  3. Trying to embed & play an mp3 file with buttons for play/pause stop & mute
    By jagerman18 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-03-2012, 02:50 AM
  4. Play Sound in Excel
    By nguyennb in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-14-2009, 04:19 AM
  5. [SOLVED] Play Sound File
    By Soniya in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-22-2006, 06:50 AM
  6. [SOLVED] Can you auto-trigger a sound file to play when a worksheet opens?
    By Nanotexan in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 02-05-2006, 01:20 PM
  7. play a WAV sound in a code... how to do it?
    By bondcrash in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-29-2005, 12:57 AM

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