Consulting

Results 1 to 7 of 7

Thread: Userform triggers Excel Crash

  1. #1

    Userform triggers Excel Crash

    Hi there

    I have a problem that is driving me crazy. I have this worbook with one click button. I you click on it, a userform with multiple controls appears.

    Sometimes however - this seems to happen randomly - my Excel application crashes. I have looked all over the internet and thought that the problem was solved; now it's back again...

    I call the userform with this macro:
    [vba]Sub Toon()
    '2 Crash oplossing 1: application.vbe.mainwindow tonen en hiden
    '1) Activate de userform via: ThisWorkbook.VBProject.VBComponents("Userform1").Activate


    Retry:
    On Error GoTo AltOploss
    '----> '1) Begin oplossing 1
    ThisWorkbook.VBProject.VBComponents("Editiescherm").Activate
    '----> '1) Einde oplossing 1
    On Error Resume Next
    Editiescherm.Show
    Exit Sub
    AltOploss:
    '----> '2) Begin oplossing 2
    On Error GoTo Retry
    Application.ScreenUpdating = False
    With Application.VBE.MainWindow
    .Visible = True
    .Visible = False
    End With
    Application.ScreenUpdating = True
    Editiescherm.Show
    On Error Resume Next
    '----> '2) Einde oplossing 2

    'zie ook
    'http://www.ozgrid.com/forum/showthread.php?t=38693
    End Sub[/vba]

    I'll try to upload the complete file here (my first post, I hope it works out right). Once again, it occurs not every time, so it's really driving me crazy...

    I had to upload it to here as it's zipped file size is > 1 MB:

    http://www.mediafire.com/?sharekey=3...4e75f6e8ebb871

    thank for your thoughts!
    Bruno

  2. #2
    Have you tried running Codecleaner against the file (dl from www.appspro.com)
    Regards,

    Jan Karel Pieterse
    Excel MVP jkp-ads.com

  3. #3
    I would like to; but I don't have administrator rights to install it :-(
    I guess I'll have to try this at home then.

  4. #4
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Post it here, we will Code Clean it and post it back.
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  5. #5
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,730
    Location
    I've had erratic results when a form (usually) got too large. You can read more about the module size issue here. I use 2007, and I think the problem is still there. I had to split a lot of Userform code out to standard modules.

    As far as I know, there is no documented limit on the size of a module. It seems the Excel development community has settled on 64KB as the size where strange problems start happening. So, as a rule of thumb, if you have a large module, it may be advantageous to split it up into smaller ones.
    To check the size of a module, export it to a text file and check that file’s size in Windows.
    http://www.dailydoseofexcel.com/arch...e-size-limits/


    I ran CodeCleaner on the file you posted, and looked at the exported files.

    Editiescherm.frx and Editiescherm.frm are 278KB and 67KB, so it might be worth trying to break that one into several modules.

    Paul

  6. #6
    Distinguished Lord of VBAX VBAX Grand Master Bob Phillips's Avatar
    Joined
    Apr 2005
    Posts
    25,453
    Location
    Paul, was the form modules size > 64k?
    ____________________________________________
    Nihil simul inventum est et perfectum

    Abusus non tollit usum

    Last night I dreamed of a small consolation enjoyed only by the blind: Nobody knows the trouble I've not seen!
    James Thurber

  7. #7
    VBAX Sage
    Joined
    Apr 2007
    Location
    United States
    Posts
    8,730
    Location
    There was only the one form (Editiescherm) and when I exported the project, the file sizes were Editiescherm.frx = 278K and Editiescherm.frm = 67KB

    The userfrom has a very large number of controls with a lot of code behind them.

    HTH

    Paul

Posting Permissions

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