3

I spent quite a lot of time in looking for the full documentation of all the C API XLM Functions without success.

I found this page which illustrate a few of them: http://msdn.microsoft.com/en-us/library/office/bb687910%28v=office.12%29.aspx

But for instance I wanted to understand and use xlfAddMenu, and I cannot find a page on MSDN that explain me.

Do you know if there is any documentation available? Apparently it is not so easy to get there.

pnuts
  • 58,317
  • 11
  • 87
  • 139
Marco
  • 319
  • 1
  • 5
  • 15

2 Answers2

0

There is no exhaustive official documentation for all C API XLM functions. However, as the documentation says following regarding C API XLM functions:

Many more functions are exposed by Excel via the C API that are useful when you are developing XLLs. They correspond to the Excel worksheet functions and functions and commands that are available from XLM macro sheets."

Also, the EXAMPLE.[C,H] files which comme with the installation of the SDK use some of these functions and you can use it to learn how to use them. For instance, the xlfAddMenu is used in the xlAutoOpen callback function.

// In the following block of code, the Generic drop-down menu is created.
// Before creation, a check is made to determine if Generic already
// exists. If not, it is added. If the menu needs to be added, memory is
// allocated to hold the array of menu items. The g_rgMenu[] table is then
// transferred into the newly created array. The array is passed as an
// argument to xlfAddMenu to actually add the drop-down menu before the
// help menu. As a last step the memory allocated for the array is
// released.
//
// This block uses TempStr12() and TempNum12(). Both create a temporary
// XLOPER12. The XLOPER12 created by TempStr12() contains the string passed to
// it. The XLOPER12 created by TempNum12() contains the number passed to it.
// The Excel12f() function frees the allocated temporary memory. Both
// functions are part of the framework library.

Excel12f(xlfGetBar, &xTest, 3, TempInt12(10), TempStr12(L"Generic"), TempInt12(0));

if (xTest.xltype == xltypeErr)
{
    hMenu = GlobalAlloc(GMEM_MOVEABLE,sizeof(XLOPER12) * g_rgMenuCols * g_rgMenuRows);
    px = pxMenu = (LPXLOPER12) GlobalLock(hMenu);

    for (i=0; i < g_rgMenuRows; i++)
    {
        for (j=0; j < g_rgMenuCols; j++)
        {
            px->xltype = xltypeStr;
            px->val.str = TempStr12(g_rgMenu[i][j])->val.str;
            px++;
        }
    }

    xMenu.xltype = xltypeMulti;
    xMenu.val.array.lparray = pxMenu;
    xMenu.val.array.rows = g_rgMenuRows;
    xMenu.val.array.columns = g_rgMenuCols;

    Excel12f(xlfAddMenu,0,3,TempNum12(10),(LPXLOPER12)&xMenu,TempStr12(L"Help"));

    GlobalUnlock(hMenu);
    GlobalFree(hMenu);
}
MikeySec
  • 81
  • 6
0

According to me the best documentation (but not updated..) is the following book : Financial Applications using Excel Add-in Development in C / C++, 2nd Edition by Steve Dalton. You can find description of the xlfAddMenu function page 332. You can also find some useful information in the chm file of the Microsoft Excel XLL Software Development Kit, including codes examples (note I did not found the xlfAddMenu in it so I guess it is a depreciated function).

Malick
  • 6,252
  • 2
  • 46
  • 59