xlSheetId

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.

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.

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.

\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;
}

Community Additions

ADD
Show:
© 2014 Microsoft