  ! This software ADOBJS.F90 is part of the Compaq Visual Fortran kit.
  ! 
  ! This software is provided as an example that demonstrates a particular
  ! feature/function of the licensed product. The software is not intended to
  ! provide a complete solution to any application problem but rather is provided
  ! as a teaching mechanism.
  ! 
  ! Users may incorporate any part of this sample into their own source after 
  ! making appropriate changes to make it suitable for the intended application.

	MODULE ADOBJECTS
	IMPLICIT NONE

  ! Object Pointers

	  INTEGER*4 excelapp
	  INTEGER*4 workbooks
	  INTEGER*4 workbook
	  INTEGER*4 worksheets
	  INTEGER*4 worksheet
	  INTEGER*4 range
	  INTEGER*4 charts
	  INTEGER*4 chart
	  INTEGER*4, DIMENSION(1:12) :: cells
	  INTEGER*4 categoryAxis
	  INTEGER*4 valueAxis

  ! BSTRs
	  INTEGER*4 bstr1
	  INTEGER*4 bstr2
	  INTEGER*4 bstr3

	CONTAINS

	  SUBROUTINE INITOBJECTS()
	
		  USE DFCOM
	
		  INTEGER i;

		  excelapp = 0
		  workbooks = 0
		  workbook = 0
		  worksheets = 0
		  worksheet = 0
		  range = 0
		  charts = 0
		  chart = 0
		  DO i=1,12
			cells(i) = 0
		  END DO
		  categoryAxis = 0
		  valueAxis = 0

		  bstr1 = 0
		  bstr2 = 0
		  bstr3 = 0
	
	  END SUBROUTINE
	  
	  SUBROUTINE RELEASEOBJECTS()
	
		  USE DFCOM
	
		  INTEGER*4 status
		  INTEGER i;

		  IF (range /= 0) status = COMRELEASEOBJECT ( range )
		  IF (chart /= 0) status = COMRELEASEOBJECT ( chart )
		  IF (charts /= 0) status = COMRELEASEOBJECT ( charts )
		  IF (worksheets /= 0) status = COMRELEASEOBJECT ( worksheet )
		  IF (worksheet /= 0) status = COMRELEASEOBJECT ( worksheet )
		  IF (workbook /= 0) status = COMRELEASEOBJECT ( workbook )
		  IF (workbooks /= 0) status = COMRELEASEOBJECT ( workbooks )
		  DO i=1,12
			  IF (cells(i) /= 0) status = COMRELEASEOBJECT ( cells(i) )
		  END DO
		  IF (categoryAxis /= 0) status = COMRELEASEOBJECT ( categoryAxis )
		  IF (valueAxis /= 0) status = COMRELEASEOBJECT ( valueAxis )
		  IF (excelapp /= 0) status = COMRELEASEOBJECT ( excelapp )

		  IF (bstr1 /= 0) CALL SysFreeString(bstr1)
		  IF (bstr2 /= 0) CALL SysFreeString(bstr2)
		  IF (bstr3 /= 0) CALL SysFreeString(bstr3)
	
	  END SUBROUTINE


	END MODULE