xlcUndo is not working when i use second time in excel2003

S

Suresh k

hi
we created addin using xll

i have attached sample code also at the end of this mail

we are using xlcUndo command to get previously typed formula and check if it
is our addin formula then we need to keep newly typed value and previous
fromula on the cell. If previous formula is not our addin formula then we
will do xlcundo to revert back to the newly typed value.

second xlcUndo is not working so we lost new value in excel2003

we are trying to use xlSet instead of xlcUndo to set old value back but
xlset has limitation saying that cell will lost UNDO information

so could you please tell me why xlcUndo is not working second time in
excel2003 ?, Is there an alternative to xlSet exists? Are xlcEnterData or
xlcInsert probable alternatives? No documentation exists explaining how to
use these.

Excel(xlfGetCell, &xlNewContents, 1, TempNum(5));
Excel(xlfGetCell, &xlNewFormula, 1, TempNum(6));

// Now UNDO, restoring the previous contents.
Excel(xlcUndo, 0, 0);
Excel(xlfGetCell, &xlPrevFormula, 1, TempNum(6));

// Get the previous contents as formula text
Excel(xlfActiveCell, &xlActiveCell, 0);
Excel(xlfGetFormula, &xlPrevFormula, 1, &xlActiveCell);
if (xlPrevFormula.xltype == xltypeStr)
{
// Test to see if the user typed on top of a SetMyVal formula
if (!_tcsncicmp(&xlPrevFormula.val.str[1], "=SetMyVal(", 8))
fYes = TRUE;

// If they wrote a new formula, allow it
if (xlNewFormula.xltype == xltypeStr)
{
if ( (unsigned char)(xlNewFormula.val.str[0]) > 0 &&
xlNewFormula.val.str[1] == '=')
{
fYes = FALSE;
}
}
}

if (fYes)
{


// Now write back the previous formula
Excel(xlcFormula, 0, 1, &xlPrevFormula);
}
else
{
// Did not meet criteria, put back the original thing the user
typed.
This is not working in excel2003
Excel(xlcUndo, 0, 0);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top