Intel® Fortran Compiler 17.0 Developer Guide and Reference

COMInitialize (W*S)

COM Subroutine: Initializes the COM library.

Module

USE IFCOM

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.

Example

Consider the following:

  program COMInitExample

    use ifwin
    use ifcom
    use ifauto

        implicit none

        ! Variables
    integer(4) word_app
    integer(4) status
    integer(INT_PTR_KIND()) 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