+ Reply to Thread
Results 1 to 12 of 12

Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

  1. #1
    Registered User
    Join Date
    03-22-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    This is a distilled form of a problem I'm having with a real application. Under certain circumstances, the initialization/activation code of a userform might result in the form losing its ability to correctly process tabs and enters: rather than switching between controls, these keys are passed to the controls themselves (even if they have TabKeyBehavior set to False). The simplest way I've found to systematically reproduce the problem is by having this at activation time:

    Please Login or Register  to view this content.
    which seemingly causes Excel to "half-steal" the focus from the userform, so to say: the userform remains focused but tab/enter processing fails. The problem immediately goes away by switching to some external app and getting back to Excel (pressing ALT+TAB twice, for instance.)

    Steps to reproduce the problem:

    Download tabnotworking.xlsm.
    Open tabnotworking.xslm.
    Enable macros.
    Click on the "Launch UserForm1" button.
    UserForm1 is displayed and the textboxes accept input from the user, but tab/enter does not work as expected.
    Press ALT+TAB twice or click on some external app and get back to the form: now tab processing works OK.
    Once tab/enter processing has been restored, further usage of the form, including relaunching it, seems to work OK (most of the time). To reliably reproduce the problem again, close the book and start from step 2.


    There are numerous references on the Internet to problems with tab processing seemingly related to this one, but no actual solution. Any clue on what's happening and how it could be solved? Thank you,
    Last edited by Joaquin M Lopez Muno; 03-22-2014 at 09:18 AM.

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Hello Joaquin M Lopez Muno,

    Welcome to the Forum.

    Change your Module1 to read:

    Please Login or Register  to view this content.
    OR: Change the Properties of the Userform's "Show Modal" to False.


    Regards.
    Last edited by Winon; 03-22-2014 at 09:46 AM. Reason: Code Tags Added. Removed Moderation.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Registered User
    Join Date
    03-22-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Hi Winon,

    I understand that showing the form in non-modal fashion hides the problem, but I really need to have the form show as modal (the user is not expected to change anything in the workbook whle within the form.)

    Digging a little more into the problem, I've checked that, when tab processing is not working, textboxes do not receive any KeyDown/KeyUp event, even though they're happily accepting input --KeyDown works again when changing focus and getting back to the form, as originally explained. Does this ring a bell?

    Also, I've corrected the formatting of my OP as suggested.

    Thank you,

  4. #4
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Hello Joaquin M Lopez Muno,

    Thank you for the feedback, and for correcting your Post.

    One easy way out is to hide a sheet when the Modeless Userform is activated, and then unhide it as soon as the Userform is closed.

    Try the attached sample Workbook.

    Regards.
    Attached Files Attached Files

  5. #5
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Just curious, why are you displaying the document properties panel?
    If posting code please use code tags, see here.

  6. #6
    Registered User
    Join Date
    03-22-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Thanks for your answer, Winon. The proposed solution does not work for me: I absolutely need the form to be modal. Thanks for trying.

  7. #7
    Registered User
    Join Date
    03-22-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Just curious, why are you displaying the document properties panel?
    For no particular reason: this is the simplest way I've found to reproduce the problem I have in my real application --there, the same effect happens though the processing work that causes it is more convoluted.

    To be clear, this is an Excel VBA runtime bug and the example merely exposes it in the simplest possible manner. If one googles for "VBA tab not working" or similar lots of results pop up describing problems most likely related to this one --but alas no solution is given.

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Hello Joaquin M Lopez Muno,

    Could you then make do with this approach?
    Attached Files Attached Files

  9. #9
    Registered User
    Join Date
    03-22-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Could you then make do with this approach?
    Hi Winon,

    I don't get what the proposed solution is: you added a TabKeyBehavior local variable in LaunchUserForm1 that seems to serve no purpose, and deleted the code in Userform_Activate that was exposing the problem. If I restore this latter sub, the problem shows again:

    tabnotworking_Rev_2.xlsm
    Last edited by Joaquin M Lopez Muno; 03-22-2014 at 12:40 PM.

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Hello Joaquin M Lopez Muno,

    Maybe you have distilled just a bit too much from a problem you are having with a real application. Do you really need to have the Userform_Activate code? Everything seems to work just fine without it.

  11. #11
    Registered User
    Join Date
    03-22-2014
    Location
    Spain
    MS-Off Ver
    Excel 2010
    Posts
    6

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Maybe you have distilled just a bit too much from a problem you are having with a real application. Do you really need to have the Userform_Activate code? Everything seems to work just fine without it.
    Unfortunately my real Activate code does need to do some pretty intensive work to load data etc. and seems that, in some environments, it's causing this weird behavior, though somehow randomly --the DisplayDocumentInformationPanel thing is just a substitute that shows the problem in an systematic manner.

    This is an elusive error that's bugged some other people over the years, and never a solution has seemingly been found. For instance, take a look at this thread:

    "VBA Form TabKeyBehavior = False is not working"

    Thank you,

  12. #12
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Sheet-related processing causes Excel VBA Userform to stop processing Tab/Enter

    Perhaps it would help if you explained, or even posted, the 'real' code?

    I'm not even sure what sheet related processing you are referrring to.

+ 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. [SOLVED] Very large sheet not processing at once.
    By comp in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 02-24-2014, 10:44 PM
  2. Reduce processing time for processing multiple excel sheets
    By rexer231 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-06-2014, 09:25 AM
  3. Replies: 17
    Last Post: 01-10-2011, 10:40 PM
  4. User Input / Processing Sheet
    By jeremymc7 in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 07-23-2008, 02:32 AM
  5. [SOLVED] Processing code on wrong sheet
    By Jeff Klein in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2005, 03: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