xlSheetId
Applies to: Excel 2013 | Office 2013 | Visual Studio
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.
Note
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 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;
}