Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conversion of f90VB code to compaq visual fortran f90code

Status
Not open for further replies.

ssv123

Programmer
Oct 7, 2003
6
US
Hi All,
I have this f90VB code, actually it should be compatible with the compaq visual fortran but I am getting errors saying the oleinitialize(),GetActiveOleObject(), and few more functions as type does not exist and should have an explicit type. I am not knowing what to do, Could any one please help me with the converted code when run in compaq visual fortran i dont get any errors....

program Example62

!Example shows how to use f90VBA to automate Excel
!Copyright (C) 1999-2000, Canaima Software, Inc.
!Illustrates:
! - Creating an new object
! - Getting an interface to an active object
! - Setting/Reviewing property values
! - Executing object methods
! - Requesting properties/Executing methods in
! an object hierarchy
! - Handling collections

use f90VBDefs
use f90VBVariants
use f90VBAutomation
implicit none

!Variants containing main objects
type(VARIANT)::Excel, WorkBook, Chart, Range
!Variants used to store temporal objects and collections
type(VARIANT)::VarTmp

integer(HRESULT_KIND)::iRet

integer::i
real::k
type(VARIANT)::IsVisible

!Initialize Ole
iRet = OleInitialize()

!If excel is already running, then get an interface
!to the running instance
Excel = GetActiveOleObject('Excel.Application',iRet)
if (iRet.ne.S_OK) then
!no instances of excel are running, create one
Excel = CreateOleObject('Excel.Application', iRet)
if (iRet.ne.S_OK) then
print *,'Cannot instantiate the Excel object. Excel might not be'
print *,'installed or properly registered in your system'
goto 1000
endif
endif

!Add a new workbook by calling Workbooks.Add method
WorkBook=ExecMethod(Excel,'Workbooks.Add')

!Get a range object from the current workbook
VarTmp=VariantCreate(VT_BSTR,'A1:B20')
Range=PropertyGet(Excel,'Range',VarTmp)
!Clear BString stored in VarTmp
call VariantClear(VarTmp)

!Set the range formulas to some random values
VarTmp=VariantCreate(VT_BSTR,'=10*RAND()')
call PropertyPut(Range,'Formula',VarTmp)
!Clear BString stored in VarTmp
call VariantClear(VarTmp)

!Add a new Chart by calling Charts.Add method
Chart=ExecMethod(WorkBook,'Charts.Add')

!Set the type of the chart to scatterplot (-4169)
call PropertyPut(Chart,'ChartType', VariantCreate(VT_I4,-4169))

!Set the range object to be the data for the chart
VarTmp=ExecMethod(Chart,'SetSourceData',Range, VariantCreate(VT_I4,2))

!Set the title for the chart
call PropertyPut(Chart,'HasTitle',VariantCreate(VT_BOOL,.true.))
VarTmp = VariantCreate(VT_BSTR,'f90VB is Easy!')
call PropertyPut(Chart,'ChartTitle.Text',VarTmp,iRet=iRet)

!We don't want to see a legend in this case, so remove it
call PropertyPut(Chart,'HasLegend',VariantCreate(VT_BOOL,.false.))

!Make the excel object visible
call PropertyPut(Excel,'Visible',VariantCreate(VT_BOOL,.true.))

!release all the currently held interfaces
call Release(Chart)
call Release(Workbook)

!close excel (uncomment next line for closing)
!VarTmp= ExecMethod(Excel,'Quit',iRet=iRet)

call Release(Excel)

1000 continue
call OLEUninitialize()

stop
end
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top