SetReferenceDlg Method (Article)

Build 1501 on 14/Nov/2017  This topic last edited on: 22/Mar/2016, at 17:07

Description

Prompts the user to select a different referenced object (picture, multi-media or URL) for the specified text.

Available in Ted and Fred.

See also SetReferenceId.

Syntax

object.SetReferenceDlg (nIdx,nFolderId)

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.

nFolderId

Id of the initial folder for the dialog used to select the object - if it is 0 the dialog starts in the same folder of the last selected object of the same kind (picture or multi-media or URL)

Remarks

A standard object selection dialog listing names, title/desk/basket and a preview is used.

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. Note that when selecting a picture it is also possible to create a new dummy one directly from the selection dialog.

Example

This function display the dialog to select a picture, and then replaces the picture, referenced with the current caption, with the selected picture.

 

Public Sub ReplaceArticlePicture()

  'v1 on 11/Dec/12 (BS) - ported from GN3

  ' Replace article picture referenced by the selected caption with another picture

  Dim objArticle = Ted.GetActiveArticle

  Dim idx As Integer = objArticle.GetCurTxtIdx

  If idx < 0 Or Not objArticle.HasRefObj(idx) Then   ' not frame member or not caption selected

     MsgBox(My.Resources.IDS_ReplaceArticlePicture2, vbCritical, My.Resources.IDS_ReplaceArticlePicture) : Exit Sub

  End If

 

  If objArticle.ToggleCheck(SwitchOn) = EOK Then

    Dim iError As Integer = objArticle.SetReferenceDlg(idx, 0)

    If iError = EOK Then

       objArticle.Save()

    End If

  End If

End Sub

Context

Article object

See also

SetReferenceId