Microsoft Knowledge Base Email Alertz

(162550) - This article describes how to insert a sound note into a cell and play the sound using a Microsoft Visual Basic for Applications macro procedure in the versions of Microsoft Excel listed above. NOTE: Microsoft Excel 97 for Windows and Microsoft Excel...

Search KbAlertz

Advanced Search

Receive Microsoft Knowledge Base articles by E-Mail?

Every night we scan the Microsoft Knowledge Base. If technologies you're interested in are updated, we'll send you an e-mail. You only get one e-mail a day, and only when new articles are added.

Click here to create a
FREE account
Already have an account?
[Click here to Login]











Microsoft Knowledge Base Article

This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks

Article ID: 162550 - Last Review: October 10, 2006 - Revision: 2.3

How to Play a Sound Note Using Visual Basic for Applications

This article was previously published under Q162550

SUMMARY

This article describes how to insert a sound note into a cell and play the sound using a Microsoft Visual Basic for Applications macro procedure in the versions of Microsoft Excel listed above.

NOTE: Microsoft Excel 97 for Windows and Microsoft Excel 98 Macintosh Edition do not support sound notes.

MORE INFORMATION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements.
  1. In a new workbook, click cell A1 on Sheet1 and click Note on the Insert menu.
  2. In the Cell Note dialog box, click Import.
  3. Open a folder that contains a sound (.wav) file to play, and then click OK. The following sound files are typically installed by Windows or the Macintosh operating systems.
          Operating system     Folder               File
          --------------------------------------------------
    
          Windows 3.x          C:\Windows           Ding.wav
          Windows 95           C:\Windows\Media     Ding.wav
          Macintosh            System Briefcase     Quack
    						
  4. In the Cell Note dialog box, click Add, and then click OK.
  5. In a new module sheet, type the following macro:
              ' Before running this macro you must insert a sound note into
          ' cell A1 on sheet1.
    
          Sub PlaySound()
    
             ' Insert a sound note into Cell A1.
             ' Test for sound capability.
             If Application.CanPlaySounds Then
                ' Play the SoundNote in cell A1.
                Worksheets("Sheet1").Range("A1").SoundNote.Play
             End If
          End Sub
    						
  6. To run the macro, click Macro on the Tools menu, select PlaySound, and then click Run.

APPLIES TO
  • Microsoft Excel 95a
  • Microsoft Excel 95 Standard Edition
  • Microsoft Excel 5.0 Standard Edition
  • Microsoft Excel 5.0c
  • Microsoft Excel 5.0 for Macintosh
  • Microsoft Excel 5.0a for Macintosh
Keywords: 
kbcode kbhowto kbprogramming KB162550
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
       

Community Feedback System

Very often, it takes hours to solve a problem. Very often, you've looked high and low, and have tried a lot of solutions. When you finally found it, chances are, it was because someone else helped you. Here's your chance to give back. Use our community feedback tool to let others know what worked for you and what didn't.

Please also understand that the community feedback system is not warranted to be correct, it's simply a system that we've built to let people try and help each other. If something in a feedback response doesn't make sense to you, or you're not comfortable making changes that the feedback talks about (like registry edits), please consult a professional.

Thank you for using kbAlertz.com Feedback System.

-- Scott Cate