XLL+ Class Library (6.3)

CXllApp::GetBinaryNameW

Retrieve a binary name from a worksheet

static BOOL GetBinaryNameW(
   const wchar_t* pszName,
   CXlBinaryNameData& data
);
static BOOL GetBinaryNameW(
   const wchar_t* pszWorkbook,
   const wchar_t* pszWorksheet,
   const wchar_t* pszName,
   CXlBinaryNameData& data
);

Parameters

pszName

The name of the invisible range in the worksheet. The name must conform to Excel range name rules.

data

A reference to a data holder which will be set to point to the binary data associated with the name, if the function is successful.

pszWorkbook

Name of target workbook.

pszWorksheet

Name of target sheet.

Return Value

The function returns TRUE if the name is found and the data is successfully retrieved, or FALSE if the name does not exist or contains no data.

CXlBinaryNameData

The data is retrieved into a CXlBinaryNameData object in order to be sure that it is locked and unlocked properly. Excel stores BinaryName data in Windows global moveable memory blocks, and the CXlBinaryNameData object ensures that the GlobalFree() method is called when the data holder goes out of scope.

You should use the CXlBinaryNameData accessor methods to access the data block: CXlBinaryNameData::GetCount and CXlBinaryNameData::GetData.

Remarks

Binary names are invisible Excel named ranges, accessible only to the add-in programmer, not to the user. They differ from visible ranges in that you cannot us them for Excel data types, only for buffers of binary data.

Binary names are held in worksheets, and are unique at worksheet level. However, there may be multiple instances of a binary name in a workbook (as many as there are worksheets in the book).

The first form of the function acts on the active sheet of the active workbook.

The second form acts on the requested sheet. In order to do so, the active workbook and sheet are changed if required, and then changed back again after the action is complete.

Example

BinaryName data can be added to the active worksheet and retrieved using code like the following:

CopyC++
// Set data 
double adValues[2] = { 1.0, 2.0 };
BOOL ok = CXllApp::DefineBinaryName("value_pair", (void*)adValues, sizeof(adValues));

// Retrieve data
CXlBinaryNameData data;
ok = CXllApp::GetBinaryName("value_pair", data);
if (ok && data.GetCount() == sizeof(adValues))
{
    memcpy(adValues, data.GetData(), sizeof(adValues));
}

Requirements

Header: xllplus.h

See Also

CXllApp Class | CXllApp Methods | CXllApp::DefineBinaryName() | CXllApp::ClearBinaryName() | CXlBinaryNameData object