Compartir a través de


xlAbort

Hace referencia a: Excel 2013 | Office 2013 | Visual Studio

Devuelve el procesador a otras tareas del sistema y comprueba si el usuario ha presionado ESC para cancelar una macro. Si el usuario ha presionado ESC durante una actualización del libro, también se puede detectar desde dentro de una función de hoja de cálculo llamando a esta función.

Excel12(xlAbort, LPXLOPER12 pxRes, 1, LPXLOPER12 pxRetain);

Parameters

pxRetain (xltypeBool)

(Opcional). Si es FALSE, esta función comprueba la condición de interrupción y borra cualquier interrupción pendiente. Esto permite al usuario continuar a pesar de la condición de interrupción. Si se omite este argumento o es TRUE, la función comprueba si un usuario anula sin borrarlo.

Valor de la propiedad/valor devuelto

Devuelve TRUE (xltypeBool) si el usuario ha presionado ESC.

Es posible que se necesiten llamadas frecuentes

Las funciones y los comandos que podrían tardar mucho tiempo deben llamar a esta función con frecuencia para producir el procesador a otras tareas del sistema.

Evitar el lenguaje confidencial

Evite usar el término "Abort" en la interfaz de usuario. Considere la posibilidad de usar "Cancelar", "Detener", "Interrumpir" o "Detener" en su lugar.

Ejemplo

El código siguiente mueve repetidamente la celda activa en una hoja hasta que transcurre un minuto o hasta que el usuario presiona ESC. En ocasiones, llama a la función xlAbort . Esto produce el procesador, lo que facilita la multitarea cooperativa.

\SAMPLES\GENERIC\GENERIC.C

int WINAPI fDance(void)
{
   DWORD dtickStart;
   XLOPER12 xAbort, xConfirm;
   int boolSheet;
   int col=0;
   XCHAR rgch[32];
//
// Check what kind of sheet is active. If it is a worksheet or macro
// sheet, this function will move the selection in a loop to show
// activity. In any case, it will update the status bar with a countdown.
//
// Call xlSheetId; if that fails the current sheet is not a macro sheet or
// worksheet. Next, get the time at which to start. Then start a while
// loop that will run for one minute. During the while loop, check if the
// user has pressed ESC. If true, confirm the abort. If the abort is
// confirmed, clear the message bar and return; if the abort is not
// confirmed, clear the abort state and continue. After checking for an
// abort, move the active cell if on a worksheet or macro. Then
// update the status bar with the time remaining.
//
// This block uses TempActiveCell12(), which creates a temporary XLOPER12.
// The XLOPER12 contains a reference to a single cell on the active sheet.
// This function is part of the framework library.
//
   boolSheet = (Excel12f(xlSheetId, 0, 0) == xlretSuccess);
   dtickStart = GetTickCount();
   while (GetTickCount() < dtickStart + 60000L)
   {
      Excel12f(xlAbort, &xAbort, 0);
      if (xAbort.val.xbool)
      {
         Excel12f(xlcAlert, &xConfirm, 2,
           TempStr12(L"Are you sure you want to cancel this operation?"),
              TempNum12(1));
         if (xConfirm.val.xbool)
         {
            Excel12f(xlcMessage, 0, 1, TempBool12(0));
            return 1;
         }
         else
         {
            Excel12f(xlAbort, 0, 1, TempBool12(0));
         }
      }
      if (boolSheet)
      {
         Excel12f(xlcSelect, 0, 1,
            TempActiveCell12(0,(BYTE)col));
         col = (col + 1) & 3;
      }
      wsprintfW(rgch,L"0:%lu",
         (60000 + dtickStart - GetTickCount()) / 1000L);
      Excel12f(xlcMessage, 0, 2, TempBool12(1), TempStr12(rgch));
   }
   Excel12f(xlcMessage, 0, 1, TempBool12(0));
   return 1;
}

Vea también

Funciones de la API de C que se pueden llamar solo desde una DLL o XLL