xlSheetId

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Finds the sheet ID of a named sheet in order to construct external references.

Excel12(xlSheetId, LPXLOPER12 pxRes, 1, LPXLOPER12 pxSheetName);

Parameters

pxSheetName (xltypeStr)

(Optional). The name of the book and sheet you want to find out about. If omitted, the xlSheetId function returns the sheet ID of the active (front) sheet.

Return Value

Returns the sheet ID in pxRes->val.mref.idSheet.

NoteNote

The pxRes->val.mref.lpmref array pointer is set to NULL after this call so that there is no need to call xlFree to release the memory that this type normally contains, although it is completely safe to do so.

Remarks

The workbook containing the specified sheet must be open to use this function. There is no way to construct a reference to an unopened workbook from a DLL. For more information about using xlSheetId to construct references, see Memory Management in Excel 2007 for examples of xltypeRef construction.

Example

\SAMPLES\EXAMPLE\EXAMPLE.C

short WINAPI xlSheetIdExample(void)
{       
   XLOPER12 xSheetName, xRes;

   xSheetName.xltype = xltypeStr;
   xSheetName.val.str = L"\022[BOOK1.XLSX]Sheet1";
   Excel12(xlSheetId, &xRes, 1, (LPXLOPER12)&xSheetName);
   Excel12f(xlcAlert, 0, 1, TempNum12(xRes.val.mref.idSheet));
   Excel12(xlFree, 0, 1, (LPXLOPER12)&xRes);
   return 1;
}

See Also

Reference

xlSheetNm

Concepts

C API Functions That Can Be Called Only from a DLL or XLL