Article ID:qGEN013
Date Revised:January 09, 1999
Keywords:OLB, IDL, enum constants, Microsoft Office, OLE, automation, .h, Word97, Excel97, Graph8
See Also:Word97 .h file   Excel97 .h file   Graph8 .h file   MS OLE/COM Viewer   

Question: How can I find a listing of the enumerated constants that are used as arguments for calls to Office97 object methods?

Answer: The constants are stored in the .OLB files that ship with programs like Microsoft Word. You can use the OLE/COM Object Viewer program to export an .IDL file that is basically a C++ compatible .H file. The following program takes the .IDL file and converts it to a set of #defines that can be used in VFP.

* 05-Oct-98 makeh.prg

* Create a VFP .h file
* This version builds the .h file in order of enum constant groups

* Based on code from Menachem Bazian

* Start up OLE/COM Object Viewer (From VC++ Tools menu) Or from start, vs, tools menu
* Use the menu: File, View TypeLib, open the .OLB
* Use the menu: File, SaveAs IDL (which may generate a truncated file so:
*   Ctrl-A in the right pane, Ctrl-C, paste the result into a text file)

lparameters pcIDLFile, pcHFile

if ( pcount() != 2 )
   wait window "Usage: makeh( cIDLFilename, cVFPHFilename )"
   return .f.
endif

create cursor temp ( cLine c(250) )
append from (pcIDLFile) type sdf

create cursor hfile ( cGroup c(32), mDefine m )

wait window "Reading" nowait

local lcDefine, lcGroup

select temp
scan
   if ( "typedef" $ cLine )
      lcDefine = ""
      do while ! ( ";" $ cLine )
         skip
         if ( ( ! ";" $ cLine ) and ( ! empty( cLine ) ) )
            lcDefine = lcDefine + "#define " + chrtran( alltrim( cLine ), ",=", "" ) + chr(13)+chr(10)
         endif
      enddo
      lcGroup = chrtran( alltrim( cLine ), ";}", "" )
      insert into hfile values ( lcGroup, lcDefine )
   endif
endscan

wait window "Writing" nowait

select hFile
index on cGroup tag cGroup
goto top

set textmerge to (pcHFile)
set textmerge on noshow

lcGroup = ""
scan
   \<<"* " + alltrim( cGroup )>>
   \<<mDefine>>
endscan

set textmerge off
set textmerge to

use in temp
use in hfile

wait clear


1