Microsoft KB Archive/87768

= Using a Linked Sound Recorder Object with OLECLIEN.VBX =

Article ID: 87768

Article Last Modified on 10/30/2003

-

APPLIES TO


 * Microsoft Visual Basic 2.0 Professional Edition
 * Microsoft Professional Toolkit for Microsoft Visual Basic programming system for Windows

-



This article was previously published under Q87768



SUMMARY
The following program demonstrates the use of the Microsoft Visual Basic OLECLIEN.VBX custom control to create a linked Sound Recorder object.

The following OLEClient property settings are required to create a Sound OLE object:   Setting      Definition ---  Class        - &quot;SoundRec&quot;

SourceDoc   - The full path of the &quot;wave&quot; file to use (for example:                  C:\WINDOWS\CHIMES.WAV)

SourceItem  - The type of sound file object. &quot;Wave&quot; is the only sound format supported by the Windows operating system version 3.1 Sound Recorder. NOTE: Sound Recorder does not come with Microsoft Windows version 3.0. You must have Windows version 3.1 to use this example. You must also have a computer capable of playing wave audio sounds (.WAV files). If you do not have a sound board, you can obtain a Windows sound driver for your PC Speaker. For information on obtaining this driver, query on the following words in the Microsoft Knowledge Base:

win31 and driver and speak.exe



MORE INFORMATION
The following program demonstrates how to create a linked Sound Recorder object in Microsoft Visual Basic for Windows by using the OLECLIEN.VBX custom control:

Step-by-Step Example
 Start Visual Basic or from the File menu, choose New Project (ALT, F, N) if Visual Basic is already running. Form1 is created by default. From the File menu, choose Add File. In the Files box, select the OLECLIEN.VBX custom control file. The OLE Client tool appears in the Toolbox. Place a command button and an OLEClient control on Form1.  Enter the following code: Sub Command1_Click OLEClient1.Class = &quot;SoundRec&quot; OLEClient1.Protocol = &quot;StdFileEditing&quot; OLEClient1.SourceDoc = &quot;c:\windows\chimes.wav&quot;

' Source Item for Sound Recorder is 'Wave', but ' Sound Recorder does not check this property so      '  any value will do. OLEClient1.SourceItem = &quot;Wave&quot;

OLEClient1.ServerType = 0 ' Linked. OLEClient1.Action = 1     ' CreateFromFile. Command1.Enabled = 0 End Sub

Sub OleClient1_DblClick OLEClient1.Action = 7 ' Activate (open for editing). End Sub

Sub Form_Unload (Cancel As Integer) OLEClient1.Action = 9 ' Close (terminate connection). End Sub  Press the F5 key to run the program. Choose the Command button to create the OLE object. Double clicking the OLEClient control starts Sound Recorder and plays the OLE sound.

<div class="references_section">