Results 1 to 7 of 7

Thread: Any Excel VBA gurus out there?

  1. #1
    Join Date
    Feb 2007
    Location
    Brisbane
    Posts
    4,497
    Total Downloaded
    0

    Any Excel VBA gurus out there?

    I've got some VBA code that's been working fine but now generates a "code execution has been interrupted" error every time it runs.

    The error occurs at the same line in the code.
    If I step through the code the error doesn't occur, only when I run the code in full.

    Had a look on the net and this appears to be a common enough problem but I haven't found an answer.

    Would appreciate any help.

    Cheers.

  2. #2
    dmdigital's Avatar
    dmdigital is offline OldBushie Vendor

    Gold Subscriber
    Join Date
    Jun 2006
    Location
    Arnhem Land, NT
    Posts
    8,492
    Total Downloaded
    0
    If you can post up the line of code it fails on that would help. Check the References to make sure it has all the libraries it needs.
    Also check your macro security settings and try removing (by renaming just to be safe) the excel.xlb file from your profile.
    MY15 Discovery 4 SE SDV6

    Past: 97 D1 Tdi, 03 D2a Td5, 08 Kimberley Kamper, 08 Defender 110 TDCi, 99 Defender 110 300Tdi[/SIZE]

  3. #3
    Join Date
    Feb 2007
    Location
    Perth
    Posts
    3,917
    Total Downloaded
    0
    try adding

    "Application.EnableCancelKey = xlDisabled" to your code so it executes first thing - something like this

    Private Sub Workbook_Open()
    Application.EnableCancelKey = xlDisabled
    End Sub

    Not sure - might help
    Last edited by Ferret; 19th May 2008 at 04:50 PM. Reason: spelling
    2024 RRS on the road
    2011 D4 3.0 in the drive way
    1999 D2 V8, in heaven
    1984 RRC, in hell

  4. #4
    Join Date
    Feb 2007
    Location
    Brisbane
    Posts
    4,497
    Total Downloaded
    0
    Turned out to be one of those Bill Gate plots...

    Earlier this afternoon I'd opened and tested some code for a status bar update to add to the app I'm writing, but the only way to stop it was a ctrl break. I'd closed the file but Excel still saw the ctrl break. I shutdown Excel, same thing.

    I rebooted and all's well. Now I remember reading something about Excel not letting go of ctrl-break commands when I was searching the net earlier.

    Thanks for the feedback guys.

  5. #5
    Join Date
    Feb 2007
    Location
    Brisbane
    Posts
    4,497
    Total Downloaded
    0
    Quote Originally Posted by Ferret View Post
    try adding

    "Application.EnableCancelKey = xlDisabled" to your code so it executes first thing - something like this

    Private Sub Workbook_Open()
    Application.EnableCancelKey = xlDisabled
    End Sub

    Not sure - might help
    Ferret, thanks for that but what are the ramification in using this for the app I'm writing?

  6. #6
    dmdigital's Avatar
    dmdigital is offline OldBushie Vendor

    Gold Subscriber
    Join Date
    Jun 2006
    Location
    Arnhem Land, NT
    Posts
    8,492
    Total Downloaded
    0
    It will disable the Esc key from working (most times). Trouble with Ctrl+Break is it can go through to the kernel interrupts and I'm not sure if this command will trap that as well.
    MY15 Discovery 4 SE SDV6

    Past: 97 D1 Tdi, 03 D2a Td5, 08 Kimberley Kamper, 08 Defender 110 TDCi, 99 Defender 110 300Tdi[/SIZE]

  7. #7
    Join Date
    Feb 2007
    Location
    Perth
    Posts
    3,917
    Total Downloaded
    0
    Quote Originally Posted by WhiteD3 View Post
    Ferret, thanks for that but what are the ramification in using this for the app I'm writing?
    It prevents the Esc key from interrupting code execution, problem is if you encounter an infinite loop you will need to ctrl/alt/delete instead. The implications of this for your application only you can say.

    I don't know exactly why your code execution is being interrupted but if you have been doing a lot of renaming of modules, deleting modules, copying parts of code from one module to another etc etc. the kinds of thing everyone does when developing large applications then occasionally whatever manages this process within VBA gets it knickers in twist.

    The complete solution is to export your modules out to text files and reimport then again so VBA rebuilds your application cleanly.

    This tedious so just go here VBA Code Cleaner download and install CodeCleaner. It is safe I have used it many times without problem but you know how it goes - backup first just to be sure

    Maybe this will fix your problem without the 'EnableCancelKey' hack. Would be interest to know if it does.
    2024 RRS on the road
    2011 D4 3.0 in the drive way
    1999 D2 V8, in heaven
    1984 RRC, in hell

Bookmarks

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 AULRO.com ONLY!
Search All the Web!