Using International Versions of Microsoft Excel

So far, you have read about running DLLs on only the U.S. version of Microsoft Excel. However, you may want to create an international DLL. This is a DLL that will work with any international version of Microsoft Excel.

The first argument to the Excel4 function, specifying which function to execute, is universal. Every version of Microsoft Excel uses the same function codes, although the name the user may see for the codes is different in international versions. For example, the SUM function is called SOMME in French Microsoft Excel, but it still uses function code 4. A problem arises only when you need to refer to this function by name; for example, if you want to place a SUM formula in a cell, and you are calling the FORMULA function. In the U.S. version, you could call FORMULA("=SUM(1,2)"), but this would not be understood in the French version.

To get around this problem, you can set the international bit (xlIntl). This tells Microsoft Excel to treat the following command as if it were executed in U.S. Microsoft Excel. As a result, setting the xlIntl bit and calling FORMULA("=SUM(1,2)") has the same effect on any version of Microsoft Excel. The French Microsoft Excel user simply sees =SOMME(1,2) entered on the sheet.

int WINAPI InternationalExample()
{
    XLOPER xResult, xSum;

    xSum.xltype = xltypeStr;
    xSum.val.str = "\012=SUM(1,2)";

    Excel4(xlcFormula | xlIntl, &xResult, 2, (LPXLOPER) &xSum, 
        TempActiveRef(237,237,1,1));

    return TRUE;
}