Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

COMCreateObject or COMGetFileObject

acar
Beginner
1,284 Views
I'm trying to get a registered COM object but failing. I have tried the following command with success:
call comcreateobject("excel.application.12",object,iret)
but I don't know the ProgID of the dll with which I want to interface. So I have tried:
call comgetfileobject("zzz",object,iret) where zzz is the full path to the dll of interest (and which is listed in the COM items under the IVF Module Wizard). Unfortunately this does not work and returns zero in object.
Do I need the ProgID of the dll to continue and if so where does one find this.
Many thanks, ACAR.
0 Kudos
4 Replies
anthonyrichards
New Contributor III
1,284 Views
I assume you mean to use ComCreateObjectFromProgID, found in module IFCOM e.g.

COMCreateObjectByProgID

DFCOM Subroutine: Passes a programmatic identifier, creates an instance of an object, and returns a pointer to the object's IDispatch interface.
Modules: USE IFCOM
Syntax
CALL COMCreateObjectByProgID
(prog_id, idispatch, status)

prog_id
The programmatic identifier of type CHARACTER*(*).

idispatch An output argument that returns the object's IDispatch interface pointer. Must be of type INTEGER(4) on ia32 processors; INTEGER(8) on ia64 processors.

status The status of the operation. It can be any status returned by CLSIDFromProgID or CoCreateInstance. Must be of type INTEGER(4).
You appear to know what you want, i.e. an Excel application instance. Do you mean to say that you do not know the exact name of the Excel object registered on your system?

Also note this from http://support.microsoft.com/kb/292491 :

Additional Notes

A common perception for Office Automation when you have multiple versions of Office installed on a system is that you can dictate which version loads by using a specific version-dependent PROGID (for example, that "Excel.Application.9" loads Excel 2000, "Excel.Application.10" loads Excel 2002 and "Excel.Application.11" loads Office Excel 2003). However, this is not correct. Excel 2000 and later versions of Excel share the same CLSID, so the version that loads with these PROGIDs depends solely on which version was last installed.

Why not try the version-independant "Excel.Application" as the ProgID? Or "Excel.Sheet.12"?
0 Kudos
acar
Beginner
1,284 Views
Thanks for that Anthony. It is actually a dll for Quick License Manager (which I think you suggested to me some time ago) that I was needing to connect to. I was unsure of its ProgID but having trawled through the registry and taken a few stabs at this I have got it to work. Also I have used the approach you recommended of applying the Fortran Module Wizard to the dll and once I'd grasped how to create the COM object then everything is going smoothly. Thanks again. ACAR.
0 Kudos
anthonyrichards
New Contributor III
1,284 Views
Well, I programmed the following in my case:

CALL COMCREATEOBJECTBYPROGID('IsLicense40.IsLicenseMgr.1', LICENSE, iRet)

if (LICENSE == 0) then
lret=MessageBox(hwnd,'Failed to create License Manager object'c, &
'Licence Manager object creation'c, &
IOR(mb_ok,IOR(MB_SYSTEMMODAL, MB_SETFOREGROUND) ))

although I cannot recall exactly where I got the information about what the PROGID was (although it might have been from the class module code in the Visual BAsic example included when I installed QLM Express)!
0 Kudos
acar
Beginner
1,284 Views
Thanks for that confirmation. I seem to have it all working nicely now!
0 Kudos
Reply