0 Replies Latest reply on Oct 11, 2017 6:23 PM by maristone

    Playing Sounds with ProcessBook VBA

    maristone

      Hello,

       

      Someone had asked me a question today about if it is possible to play sounds with a ProcessBook VBA.  The answer is yes and here is an example of some code I used to play a .mid file.  First I need to declare the function and load it from the correct library:

       

       

      Once we have the function now we just need to pass in the proper input which is the file path.  In this example I just used a file in the %systemroot% directory.  I created a button on my ProcessBook display and linked it to a new macro I called Groove.  Then in the Visual Basic Editor I used the following code:

       

       

      Now when I click the button it starts playing the sound file.  Note that if you would like to stop playing the sound file you can use the "mciExectute ("Stop " & MIDIFile)" command.

       

      Here is a link to some code to play .wmv files but will operate in the same basic procedure I showed here:

       

      How to play a wave file or sound file using VBA - Stack Overflow

       

      Let me know if anyone has any questions about this.

       

      Menotti Aristone

      maristone@osisoft.com