Creating an instance of an object
To create an instance of the object, Example 6.1 calls function CreateOleObject:
IE = CreateOleObject('InternetExplorer.Application', iRet)
There are two important things to note in this function. First, it returns a variant value, which in this case is stored in variable IE. Second, you pass the programmatic identifier (ProgID) of the object as an argument [38]. Function CreateOleObject checks the registry for the requested object. If the object has been registered, the function then instantiates the object and requests it’s IDispatch interface. So the variant returned by CreateOleObject is of type VT_DISPATCH and contains a pointer to the object’s IDispatch interface. In other worlds, CreateOleObject performs steps two and three as explained above. You can create instances of objects using three other functions provided by f90VB; CreateComObject, CreateRemoteComObject and CreateRemoteOleObject. The first two functions return variants containing IUnknown interfaces (i.e. variants of type VT_UNKNOWN), the last function returns a variant of type IDispatch, and can be used to create objects in a remote server.
If CreateOleObject is successful, S_OK is returned in argument iRet. If the function cannot find the requested object, or if the object does not expose an IDispatch interface, the function returns an error condition in iRet (a negative value), and an empty variant (i.e. a Variant of type VT_EMPTY).