Description
Replaces a referenced object with a specified one (by id).
Similar to SetReferenceDlg but specifying the id instead of letting the user chose via a dialog
Available in Ted and Fred.
Syntax
object.SetReferenceId nIdx,nId |
object
Required. Object name. Returned by Ted.GetActiveArticle.
nIdx
Index of the text to change, ranging from 0 = first text in the article to NTxts-1 = last text in the article. If nIdx is outside this range a run-time error is raised. To get the idx of the current element, use GetCurTxtIdx.
nId
Id of the picture to insert
Remarks
The method fails with an error message if the text does not support a referenced object. See HasObj for methods to check it in a script. See also Id to find out the ID of the existing object.
Example
This script replaces the object, referenced with the current text, with the object of the same class, with ID=4.
Dim objArticle = Ted.GetActiveArticle
Dim idx As Integer = objArticle.GetCurTxtIdx
Dim replObjId As Integer = 4
If objArticle.ToggleCheck(SwitchOn) = 0 Then
objArticle.SetReferenceId(idx, replObjId)
End If
Context
Article object