Partager via


xlAbort (traduction automatique)

Dernière modification : mercredi 18 mars 2009

S’applique à : Excel 2010 | Office 2010 | VBA | Visual Studio

Important

Cet article a été traduit automatiquement, voir l’avertissement. Vous pouvez consulter la version en anglais de cet article ici.

Libère le processeur pour les autres tâches du système et vérifie si l’utilisateur a appuyé sur ESC pour annuler une macro. En appelant cette fonction, une fonction du classeur peut également détecter si l’utilisateur a appuyé sur ESC durant le recalcul d’un classeur.

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

Paramètres

pxRetain (xltypeBool)

(Facultatif). Si FALSE, cette fonction vérifie la condition d'arrêt et efface un arrêt en attente. Cela permet à l'utilisateur continuer en dépit de la condition d'arrêt. Si cet argument est omis ou a TRUE, la fonction recherche un abandon de l'utilisateur sans effacer le contenu.

Valeur de propriété/Valeur renvoyée

Renvoie le TRUE (xltypeBool) si l'utilisateur a appuyé sur ESC.

Notes

Avertissement traduction automatique : cet article a été traduit par un ordinateur, sans intervention humaine. Microsoft propose cette traduction automatique pour offrir aux personnes ne maîtrisant pas l’anglais l’accès au contenu relatif aux produits, services et technologies Microsoft. Comme cet article a été traduit automatiquement, il risque de contenir des erreurs de grammaire, de syntaxe ou de terminologie.

Remarques

Appels fréquents peuvent s'avérer nécessaires.

Fonctions et commandes peuvent prendre beaucoup de temps doivent appeler cette fonction fréquemment afin de produire du processeur à d'autres tâches dans le système.

Éviter de langage sensible

Évitez d'utiliser le terme « Abandon » dans votre interface utilisateur. Envisagez d'utiliser "Annuler", "Arrêt", "Break" ou « Stop » à la place.

Exemple

Le code suivant déplace à plusieurs reprises la cellule active sur une feuille jusqu'à ce qu'une minute écoulée ou jusqu'à ce que l'utilisateur appuie sur ESC. Il appelle la fonction xlAbort occasionnellement. On obtient ainsi le processeur, ce qui facilite de multitâche coopérative.

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

Voir aussi

Concepts

Fonctions de l’API C appelables uniquement depuis une DLL ou XLL (traduction automatique)