Manage Learn to apply best practices and optimize your operations.

Play a sound from the Lotus Notes client using LotusScript and OLE

Learn an alternative method to using the NotesUIWorkspace PlayTune to play sounds from a Lotus Notes client that uses Object Linking and Embedding (OLE) and LotusScript and doesn't require the sound file to be stored locally.

You can use NotesUIWorkspace PlayTune to play a sound from a Lotus Notes client.

However, this method requires you to already have the sound file on the client computer hard drive in a specific location, which isn't always possible or convenient. In this tip, I explain another way you can play a sound in Lotus Notes using Object Linking and Embedding (OLE) and LotusScript.

  1. Open a Lotus Notes document in edit mode and put the cursor in a rich-text field.

    Note: If this is a Lotus Notes email, anywhere in the body of the email will do.

  2. Choose the menu option "Create -> Object."
  3. Choose the "object from a file" option, browse to the wave file and click "OK."
  4. [OPTIONAL] Right-click the attached file (it should have an icon that looks like a stereo speaker). Choose the option "Object Properties" and then give the object a descriptive name.
  5. Add a space after the attached file icon and choose the menu option "Create -> Hotspot -> Button."
  6. Give the button a meaningful label, such as "Play Sound."
  7. The formula editor for this button should be visible on the bottom part of the screen. If it's not, right click the button and choose the option "Edit Button." Change the language type to LotusScript, and enter the following code:
    Dim ws As New NotesUIWorkspace
    Dim doc As NotesDocument
    Set doc = ws.CurrentDocument.Document
    Forall obj In doc.EmbeddedObjects
    '** this will attempt to play all Sound Recorder objects
    If (obj.Class = "SoundRec") Then
        Call obj.DoVerb("&Play")
    End If
    '** this will attempt to play a specific object (use
    '** whatever name you used in step 4 above)
    'If (obj.Name = "MySound") Then
    ' Call obj.DoVerb("&Play")
     'End If
        End Forall
  8. Lastly, click somewhere else on the Lotus Notes document to get out of the script editor. Now either save the document, or send the email message, if it is an email.

Do you have comments on this tip? Let us know.

This tip was submitted to the tip library by member Chandra Teja. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

More LotusScript resources:

Dig Deeper on LotusScript

  • Favorite iSeries cheat sheets

    Here you'll find a collection of valuable cheat sheets gathered from across the iSeries/ community. These cheat ...