Tip

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

You can use NotesUIWorkspace PlayTune to play a sound from a Lotus Notes client.
More LotusScript resources:
30 LotusScript tips

LotusScript Learning Guide

LotusScript Reference Center

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 SearchDomino.com 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.

This was first published in November 2007

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.