Examples: activate method

  1. This script embeds a new object in the Body item of a document, and activates the object.
    Dim session As New session
    Dim doc As Document
    Dim rtitem As RichTextItem
    Dim object As EmbeddedObject
    Dim handle As Variant
    Set doc = New Document( session.CurrentDatabase )
    Set rtitem = New RichTextItem( doc, "Body" )
    Set object = rtitem.EmbedObject _
    ( EMBED_OBJECT, "Microsoft Excel Worksheet", "", _
    "Report" )
    Set handle = object.Activate( false )
    If ( handle Is Nothing ) Then
      doc.Subject = "This object has no OLE automation interface"
    Else
      doc.Subject = "This object has an OLE automation interface"
    End If
    Call doc.Save( true, true )
  2. This script embeds a new worksheet object in a rich text item, activates it, and uses its handle to set the value of a cell in the worksheet.
    Dim rtitem as RichTextItem
    Dim object as EmbeddedObject
    Dim handle as Variant
    '...set value of rtitem...
    Set object  = rtitem.EmbedObject( EMBED_OBJECT, _
    "Microsoft Excel Worksheet", "", "Report" )
    Set handle = object.Activate ( false )
    handle.Cells( 1,1 ).Value = 100
    handle.Parent.Save