+ Reply to Thread
Results 1 to 4 of 4

Trap Excel's application Spell Check for Cancel or Close events

  1. #1
    Registered User
    Join Date
    12-21-2009
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Trap Excel's application Spell Check for Cancel or Close events

    I am familiar working with application events such as before workbook close etc...however my current issue is this - I have a script that spell checks a specific range of cells, skipping cells with a specific criteria. As a result of this approach, the check spelling application is opened within a loop - I would like to trap/capture when the user hits Cancel or the red X to close the app so I can then exit the loop before re-launching the app in the next loop. This is not a custom form, so is there a reference to all application events for all apps (such as spell check) within Excel? Example that is not accurate but will give you an idea of what I am looking for - this is adapted from a Form control example:

    Private Sub application_Spelling(Cancel As Integer, CloseMode As Integer)
    If cancelled or closed Then exit the calling sub

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Trap Excel's application Spell Check for Cancel or Close events

    If you're using the Range.CheckSpelling method, it will return a True if the user clicked Change (or Change All) and False if canceled.

    Please Login or Register  to view this content.
    Last edited by AlphaFrog; 03-21-2015 at 05:43 PM.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    12-21-2009
    Location
    Chicago, IL
    MS-Off Ver
    Excel 2007
    Posts
    4

    Re: Trap Excel's application Spell Check for Cancel or Close events

    Very close AlphaFrog....this works to now exit the sub, however there is an interesting side effect, the cell is no longer highlighted (cell cursor does not move to the cell found with a spelling error), although spell check seems to continue to function normally? Full code is below, I have commented out code added by your suggestion (I have also tried to place this in various positions within the macro, all with the same side effect), this will work as-is on all cells not Locked, but you have to interrupt/break the macro to exit.

    Please Login or Register  to view this content.
    Last edited by pvt2do; 03-21-2015 at 07:03 PM.

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,643

    Re: Trap Excel's application Spell Check for Cancel or Close events

    Did you commented out this (below) and try it with just the suggestion?
    Please Login or Register  to view this content.
    Try this...
    Please Login or Register  to view this content.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 11-28-2014, 07:09 AM
  2. Replies: 1
    Last Post: 10-20-2014, 11:01 AM
  3. Workbook Close application: 'Cancel' problem???
    By arfanvilla in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-21-2008, 06:01 AM
  4. [SOLVED] [URGENT] How to Trap Excel Window Scroll Events in VSTO
    By Surjya in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-24-2006, 12:00 PM
  5. [SOLVED] Excel addin from C# - Trap excel events
    By Karthikeyan N in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-04-2005, 05:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1