+ Reply to Thread
Results 1 to 8 of 8

Code morphing stops VBA

  1. #1
    Registered User
    Join Date
    09-17-2014
    Location
    Tegucigalpa, Honduras
    MS-Off Ver
    MS Office 2013 x64
    Posts
    5

    Question Code morphing stops VBA

    Hello everybody. I'm new here, sorry for rushing out so fast to post this, but it's an emergency. Also, this might as well be the most technical Excel VBA question ever.
    In my project I have a form that lets the user write their own VBA code and run it via Module Insertion. It used to work fine (you open the form, type some VBA code, press run, and voilá) until today.
    I had to make a small change in the project, I just edited a little piece on ABSOLUTELY-UNRELATED code on another form, and suddenly, when I was testing it with my VBA scripter form, when I hit Run, the whole execution of VBA stopped. Everything but Excel closed, and now, I can't keep it from automatically shutting down the execution when the event of the button finishes. This has become really anoying, since I was already creating my own separate debugging files to load on it.
    Here is the source code for the VBA Scripter window if you need it.

    Please Login or Register  to view this content.
    Note: The code on the script window does execute, but everything stops right away when the BtnRun_Click event finishes.

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

    Re: Code morphing stops VBA

    Does removing all the On Error... stuff in the posted code, and all other code, shed any light on the problem?

    PS Got to ask, why have you created code for the user to create code via a userform? Couldn't they just use the VBE?
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-17-2014
    Location
    Tegucigalpa, Honduras
    MS-Off Ver
    MS Office 2013 x64
    Posts
    5

    Re: Code morphing stops VBA

    No, any of the error handlers trigger.
    why have you created code for the user to create code via a userform? Couldn't they just use the VBE?
    Good question...
    It was first intender for me to debug code on the fly in a smaller window in case of an error (due to Excel crashing randomly when debugging in the VBE) and also to perform quick calculations in the form of vba expressions. Then I found it useful as a sidetool for a Console window that I've made as well.
    for the moment it is there for the sole purpose of running temporary functions, kind of like, having a for-next cycle doing some stuff and showing me the result while executing another form. Due to the amount of info that I have to introduce in the application, it was frustrating to start over again because I forgot to calculate soemthing, or because a weird error appeared, and I can't stand losing my work due to debugging at the randomly crashing VBE.
    Edit: of course, removing all of the Module-generation and Module-deletion code makes it work fine.
    Last edited by TheXDS; 09-17-2014 at 01:14 PM.

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

    Re: Code morphing stops VBA

    What do you mean by 'No, any of the error handlers trigger'?


    Couldn't you just use the Immediate window for on the fly calculations?

  5. #5
    Registered User
    Join Date
    09-17-2014
    Location
    Tegucigalpa, Honduras
    MS-Off Ver
    MS Office 2013 x64
    Posts
    5

    Re: Code morphing stops VBA

    Ok, I removed the 'On error goto...' stuff, and it still closes everything.
    about the Immediate window, yeah, that would be nice, if I didn't have to use for-next cycles to get some results.
    (about doing it like:
    For A=0 to 10:Msgbox A: Next
    )
    No, some of the For cycles aren't that simple.

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

    Re: Code morphing stops VBA

    Why not use a separate instance of Excel?

    PS Did you remove On Error from all the code, including the code being created?

  7. #7
    Registered User
    Join Date
    09-17-2014
    Location
    Tegucigalpa, Honduras
    MS-Off Ver
    MS Office 2013 x64
    Posts
    5

    Re: Code morphing stops VBA

    The other instance of Excel might be the only option I guess, even if I can't properly debug from there...
    And, yeap... I also removed that from the code being generated.
    BTW, I started notticing something about the forms... at first, the focus was on the input textbox (when it was working nice) and now, it doesn't have it... hmmm... weird...
    Thanks.... :/

  8. #8
    Registered User
    Join Date
    09-17-2014
    Location
    Tegucigalpa, Honduras
    MS-Off Ver
    MS Office 2013 x64
    Posts
    5

    Re: Code morphing stops VBA

    !!!!! You won't believe it! I (kind of) Fixed it!
    It was due to the forms being shown as modeless, whereas modal will make them stay onscreen and not unload.
    (yes, I remember doing that little change before testing the form today)
    Strange.

+ 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. Removing code line stops code working?!?!?
    By adamj1910 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-31-2012, 02:36 PM
  2. Migrating & Morphing Formulas
    By nozmo50 in forum Excel General
    Replies: 3
    Last Post: 10-07-2007, 04:08 PM
  3. [SOLVED] Code stops when high lighting (Chips code)
    By ste mac in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 05-02-2006, 08:45 AM
  4. VB Code stops working
    By Michelle K in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-28-2005, 05:06 PM
  5. [SOLVED] Code stops at range
    By Pat in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-16-2005, 03:04 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