Function Main As String
' Show draw object methods

' THE EXAMPLE ILLUSTRATES THE USE OF:
'   Item
'   GetType
'   GetBound
'   SetBound
'   Kill


Dim s,dcr As String, i,j,n,nd,k,l,t,w,h As Integer, Obj,Page As Object
Const title="SHOW DRAW OBJECTS METHODS"


  k=MBB_OK + MBI_INFORMATION
  dcr=Chr(13)+Chr(13)

  Page=ActiveDocument.ActivePage

  If Page.Drawings.Count<1 Then
    i=MessageBox("Your page is empty, sorry", title, k)
    Goto ShutDown
  EndIf

  'Removing all ellipses
  j=MessageBox("Press OK to delete all ellipses", title, k)
  n=0
  For i=Page.Drawings.Count To 1 Step -1
    Obj=Page.Drawings.Item(i)
    If Obj.GetType=CS_ELLIPSE Then
      Kill(Obj)
      n=n+1
    EndIf
  Next i
  j=MessageBox(Str(n)+ " ellipses found/deleted", title, k)

  'Making all rectangles twice as large
  j=MessageBox("Press OK to enlarge all rectangles twice", title, k)
  n=0
  For i=Page.Drawings.Count To 1 Step -1
    Obj=Page.Drawings.Item(i)
    If Obj.GetType=CS_RECTANGLE Then
      Obj.GetBound(l,t,w,h)
      Obj.SetBound(l,t,2*w,2*h)
      n=n+1
    EndIf
  Next i
  j=MessageBox(Str(n)+ " rectangles found/enlarged", title, k)

ShutDown:
  Main="Demo completed"
End Function