COM Subroutine: Initializes the COM library.
Module: USE IFCOM
Syntax
CALL COMInitialize (status)
status
The status of the operation. It can be any status returned by OleInitialize. Must be of type INTEGER(4).
You must use this routine to initialize the COM library before calling any other COM or AUTO routine.
See Also
OleInitialize in the Microsoft* Platform SDK
Examples
Consider the following:
program COMExample
use ifwin
use ifcom
use ifauto
implicit none
! Variables
integer(4) word_app
integer(4) status
integer(4) invoke_args
call COMInitialize(status)
! Call GetActiveObject to get a reference to a running MS WORD application
call COMGetActiveObjectByProgID("Word.Application", word_app, status)
if (status >= 0) then
! Print the active document
invoke_args = AutoAllocateInvokeArgs()
call AutoAddArg(invoke_args, "Copies", 2)
status = AutoInvoke(word_app, "PrintOut", invoke_args)
call AutoDeallocateInvokeArgs(invoke_args)
! Release the reference
status = COMReleaseObject(word_app)
end if
call COMUninitialize()
end program