Developer Guide and Reference

ID 767251
Date 10/31/2024
Public
Document Table of Contents

COMInitialize

COM Subroutine: Initializes the COM library. This routine is only available for Windows.

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