Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA Forms in Excel crashing on exit?

Hi,

I've made various forms in excel which are used to log types of calls
received at work, amongst other things.

The problem I have will ALL of them is that when anyone exits the
workbook after using it, Excel crashes and auto-recovers but I can't
work out what I'm doing wrong. I've tried the Unload (form) command, but
this doesn't seem to have made any difference.

The only thing I can think of is that I'm a bit lazy and don't always
declare variables, but the forms don't really use them anyway... Just a
couple are used for very basic validation of entries.

Unfortunately, I can't post code examples as they are at work and have
no way of getting them home, but I'm hoping this is a simple beginner's
mistake!?

Thanks for any advice in advance!
Dom
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default VBA Forms in Excel crashing on exit?

Dom,

You aren't going to get much help without posting some code.
However, you could put "Option Explicit" as the first line
in every module and see what you come up with.

Does the workbook function on your computer but not on other computers?

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware


"Dom" wrote in message
...
Hi,
I've made various forms in excel which are used to log types of calls
received at work, amongst other things.
The problem I have will ALL of them is that when anyone exits the
workbook after using it, Excel crashes and auto-recovers but I can't
work out what I'm doing wrong. I've tried the Unload (form) command, but
this doesn't seem to have made any difference.

The only thing I can think of is that I'm a bit lazy and don't always
declare variables, but the forms don't really use them anyway... Just a
couple are used for very basic validation of entries.

Unfortunately, I can't post code examples as they are at work and have
no way of getting them home, but I'm hoping this is a simple beginner's
mistake!?

Thanks for any advice in advance!
Dom
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA Forms in Excel crashing on exit?

Jim Cone wrote:

Does the workbook function on your computer but not on other computers?


No... The same error occurs on whatever computer I run it on.
What does the "Option Explicit" actually do?

Thanks for the pointer - I'll give it a try on Monday!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default VBA Forms in Excel crashing on exit?

1. Option Explicit will catch any misspelled variables.
You could think you are referring to one thing and Excel
could be seeing it as something else... lngNum vs. 1ngNum for instance.
2. It will also force you to declare all of your variables.
Undeclared variables become Variants, not always a good thing.
Also, make sure you compile the project before trying to run your code.
That can also point out problems...Debug | Compile VBAProject.

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Dom" wrote in message
...
Jim Cone wrote:

Does the workbook function on your computer but not on other computers?


No... The same error occurs on whatever computer I run it on.
What does the "Option Explicit" actually do?

Thanks for the pointer - I'll give it a try on Monday!
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default VBA Forms in Excel crashing on exit?

Jim Cone wrote:
1. Option Explicit will catch any misspelled variables.
You could think you are referring to one thing and Excel
could be seeing it as something else... lngNum vs. 1ngNum for instance.
2. It will also force you to declare all of your variables.
Undeclared variables become Variants, not always a good thing.
Also, make sure you compile the project before trying to run your code.
That can also point out problems...Debug | Compile VBAProject.

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Dom" wrote in message
...
Jim Cone wrote:


Does the workbook function on your computer but not on other computers?



No... The same error occurs on whatever computer I run it on.
What does the "Option Explicit" actually do?

Thanks for the pointer - I'll give it a try on Monday!


The code itself runs fine... The form does it's job perfectly, it's when
the excel file is actually closed that the problem occurs - Excel
crashes and auto-recovers the file. It doesn't affect the
functionability of the form but is REALLY annoying when trying to
shutdown... I'm guessing it can't happen to everyone else, but I can't
see what might cause it. Would an undeclared variable cause this?



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default VBA Forms in Excel crashing on exit?

"Would an undeclared variable cause this?"

I don't know.
It might be interesting to see what kind of problems occur
when unloading UserFormI instead of UserForm1...
It is hard to diagnose the illness without seeing the patient.
Jim Cone


"Dom"
wrote in message...
Jim Cone wrote:
1. Option Explicit will catch any misspelled variables.
You could think you are referring to one thing and Excel
could be seeing it as something else... lngNum vs. 1ngNum for instance.
2. It will also force you to declare all of your variables.
Undeclared variables become Variants, not always a good thing.
Also, make sure you compile the project before trying to run your code.
That can also point out problems...Debug | Compile VBAProject.

Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware



"Dom" wrote in message
...
Jim Cone wrote:


Does the workbook function on your computer but not on other computers?



No... The same error occurs on whatever computer I run it on.
What does the "Option Explicit" actually do?

Thanks for the pointer - I'll give it a try on Monday!


The code itself runs fine... The form does it's job perfectly, it's when
the excel file is actually closed that the problem occurs - Excel
crashes and auto-recovers the file. It doesn't affect the
functionability of the form but is REALLY annoying when trying to
shutdown... I'm guessing it can't happen to everyone else, but I can't
see what might cause it. Would an undeclared variable cause this?

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Exiting a macro and aesthetics


Dear all,

from the previous contributions on the "Exiting a macro" I conclude
that it is impossible to leave a macro immediately in case of
an error in a subroutine.

Is this really true??

Please have a look at the following simple structure of a macro which
is consisting of a large number of subroutines:
''''''''''''''''''''''''''''''''''''''''''''''''''
Sub myMain()

Call mySUB1
Call mySUB2
..
..
Call mySUBn

End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''
My aim is to keep the macro as simple as possible in case it detects an
error in a (sub-)subroutine.
I would like to have only one single type of behaviour:

1) tell the user which error occurred
2) stop the macro altogether

in my case the primitive behaviour is justified because errors will
be rare but always have to be corrected manually.

From what I understood the only way is to do it like follows:
''''''''''''''''''''''''''''''''''''''''''''''''''
Global GiveUp as Boolean
Sub myMain()

GiveUp = False
Call mySUB1 : If GiveUp Then Exit sub
Call mySUB2 : If GiveUp Then Exit sub
..
..
Call mySUBn

End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''
and set GiveUp = True in case one of the expected errors occurs.
This is ugly, and gets worse if the mySUB.. consist themselves
of subroutines.

Is there really no "Exit macro" type of statement?

Thanks in advance for either confirming my suspicions or
- better - showing me a way out

Best regards, Bernd
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crashing excel on exit Lieth Excel Programming 0 January 2nd 06 03:07 PM
Use of forms in Excel causes crashing Arjen Leine Excel Programming 3 November 5th 04 04:09 PM
VBA - Forms Exit Errors jordanctc[_5_] Excel Programming 1 June 30th 04 07:14 PM
Calling Forms from Forms - Exit problems Stuart[_5_] Excel Programming 3 May 25th 04 06:50 AM
If a called sub exit, how to the caller exit right away? luvgreen[_4_] Excel Programming 4 February 24th 04 05:06 PM


All times are GMT +1. The time now is 01:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"