Handling array arguments.
BasicATLServer1.zip
-
Open BasicATLServer and add another interface.
- Open the project and go to the idl file.
- Declare IArrayAccess interface.
- Include definition of IArrayAccess into the coclass clause.
- Open TheCoClass header file and add the IArrayAccess to the base classes.
- Add IArrayAccess to the COM MAP.
- Use COM_INTERFACE_ENTRY_IID macro to resolve ambiguity of IDispatch in the class hierarchy.
- Add C++ prototypes for the functions of IArrayAccess.
- Build the project. It compiles but the linker is missing the implementations.
-
Implement the IArrayAccess functions.
Add the implementations:
TheCoClass.cpp
Variant.h
SafeArray.h
Variant.cpp
-
Build and test the client application.
- In the VBA IDE goto Tools\references and check the server in.
- Add the VBA code
to a worksheet module.
- Test the sum function. Highlight a range. At right click the sum
of all numeric values in the range appears to the right
of the last cell of the highlighted range.
- Test the getArray function. At double click previous results of the
right click operation are displayed.