Share via


balance Property

Retrieves an Integer between -10,000 and +10,000 that represents how the volume of the background sound is divided between the left and right speakers.

expression.balance

*expression   * Required. An expression that returns one of the objects in the Applies To list.

Remarks

A -10,000 value indicates that all sound is directed to the left speaker. A +10,000 value indicates that all sound is directed to the right speaker. A 0 value indicates that the sound is balanced between the left and right speakers.

Example

The following example creates a BGSOUND element in the specified document, if one doesn't already exist, and formats the src, balance, loop, and volume properties.

Sub InsertSound(ByRef objDoc As FPHTMLDocument, ByRef strSoundFile As String, _
        ByRef intBalance As Integer, ByRef intLoop As Integer, _
        ByRef intVolume As Integer)
        
    Dim objHead As IHTMLElement
    Dim objSound As FPHTMLBGsound
    
    Set objSound = objDoc.all.tags("bgsound").Item(0)
    
    If objSound Is Nothing Then
        Set objHead = objDoc.all.tags("head").Item(0)
        objHead.insertAdjacentHTML "beforeEnd", "<BGSOUND id=""bgsound"">"
        Set objSound = objHead.all.tags("bgsound").Item("bgsound")
    End If
    
    With objSound
        .src = strSoundFile
        .balance = intBalance
        .loop = intLoop
        .volume = intVolume
    End With
    
End Sub

Use the following example to call the preceding subroutine. This example assumes that you have a sound file named "cashreg.wav" in a folder named "sounds" in the active Web site.

Sub CallInsertSound()

    Call InsertSound(objDoc:=ActiveDocument, strSoundFile:="sounds/cashreg.wav", _
        intBalance:=0, intLoop:=1, intVolume:=0)

End Sub

Applies to | FPHTMLBGsound Object | IHTMLBGsound Object