Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA Causing Excel To Crash

This is my first post onto the group and I appologise for the length of
it, but I felt some background would be useful.

I have recently started building a system using Excel and VBA. Whilst
my experience in coding VBA is limited I have been programming for a
long time and have used other languages including Java.

Coming from a Java background I am keen to use an OO approach and spent
some time investigating other peoples views. In conclusion I decided
that the project could be done in OO style and I have mapped each
business process to a Class in VBA. All my classes are 'Public Not
Creatable' and I have one Module containing a method for each class
that creates an instance. ( a 'Constructor' if you like). On the whole
this approach has served me well, allowing for good code separation and
re-use.
I have also used Interfaces as a 'work around' to inheritance and
although a little clumsy I continue to use it, If at some time in the
future the code is migrated to another environment like C# or indeed
Java then this approach will prove useful.

However, during the programming day I get quite a lot of odd behaviour
and Excel crashes. I am wondering wether or not I am missing something
basic in my approach. In fact Excel crashes so often I have also
written some basic VBA code to export all my modules out to text files,
delete them from the work book, then re-import them afterwards. This
process does seem to fix most problems but eventually new ones appear.

The most recent is a line of code 'Set v_MyClassA = new clsMyClassA'
this actually calls the Class_Initialize of clsMyClassB. Again I
exported all the modules then re-imported them and it has now fixed the
problem. But why, why, why !!!!

I would appreciate it anybody could share their experience and perhaps
highlight a basic problem in my approach.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default VBA Causing Excel To Crash

Gareth,
There nothing wrong with your approach ; you're merely using the constructs
available to the language.
However, as VBA stores code in a variety of compiled states whilst active
(and in the workbook), the IDE can become confused with multiple complex
changes.
It may help to do a full compile (DebugCompile VBA Project) and fix any
errors found.
If you are using API calls, ensure you check their success/failure (if
possible), as VBA has no knowledge of them.

Some people do report frequent crashes although I seldom experience this
problem. Whether due to your installation, add-in, Windows etc.. I can't
say.
Not much help, but nothing in your description indicates a cause.

NickHK

"Gareth" wrote in message
ups.com...
This is my first post onto the group and I appologise for the length of
it, but I felt some background would be useful.

I have recently started building a system using Excel and VBA. Whilst
my experience in coding VBA is limited I have been programming for a
long time and have used other languages including Java.

Coming from a Java background I am keen to use an OO approach and spent
some time investigating other peoples views. In conclusion I decided
that the project could be done in OO style and I have mapped each
business process to a Class in VBA. All my classes are 'Public Not
Creatable' and I have one Module containing a method for each class
that creates an instance. ( a 'Constructor' if you like). On the whole
this approach has served me well, allowing for good code separation and
re-use.
I have also used Interfaces as a 'work around' to inheritance and
although a little clumsy I continue to use it, If at some time in the
future the code is migrated to another environment like C# or indeed
Java then this approach will prove useful.

However, during the programming day I get quite a lot of odd behaviour
and Excel crashes. I am wondering wether or not I am missing something
basic in my approach. In fact Excel crashes so often I have also
written some basic VBA code to export all my modules out to text files,
delete them from the work book, then re-import them afterwards. This
process does seem to fix most problems but eventually new ones appear.

The most recent is a line of code 'Set v_MyClassA = new clsMyClassA'
this actually calls the Class_Initialize of clsMyClassB. Again I
exported all the modules then re-imported them and it has now fixed the
problem. But why, why, why !!!!

I would appreciate it anybody could share their experience and perhaps
highlight a basic problem in my approach.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default VBA Causing Excel To Crash

NickHK

Thanks for your reply. I have done a little reading on add-ins and I
understand I could convert my project to an xla and therefore seperate
my code from the workbook which in essence is just being used as the
presentation layer.
Do you have any views in that direction ?

Also I didn't mention yesterday that I am writing code against MS
SQLServer using ActiveX Data Objects 2.8. I wonder if there are any
known issues when using this library ?

Thanks again

NickHK wrote:

Gareth,
There nothing wrong with your approach ; you're merely using the constructs
available to the language.
However, as VBA stores code in a variety of compiled states whilst active
(and in the workbook), the IDE can become confused with multiple complex
changes.
It may help to do a full compile (DebugCompile VBA Project) and fix any
errors found.
If you are using API calls, ensure you check their success/failure (if
possible), as VBA has no knowledge of them.

Some people do report frequent crashes although I seldom experience this
problem. Whether due to your installation, add-in, Windows etc.. I can't
say.
Not much help, but nothing in your description indicates a cause.

NickHK

"Gareth" wrote in message
ups.com...
This is my first post onto the group and I appologise for the length of
it, but I felt some background would be useful.

I have recently started building a system using Excel and VBA. Whilst
my experience in coding VBA is limited I have been programming for a
long time and have used other languages including Java.

Coming from a Java background I am keen to use an OO approach and spent
some time investigating other peoples views. In conclusion I decided
that the project could be done in OO style and I have mapped each
business process to a Class in VBA. All my classes are 'Public Not
Creatable' and I have one Module containing a method for each class
that creates an instance. ( a 'Constructor' if you like). On the whole
this approach has served me well, allowing for good code separation and
re-use.
I have also used Interfaces as a 'work around' to inheritance and
although a little clumsy I continue to use it, If at some time in the
future the code is migrated to another environment like C# or indeed
Java then this approach will prove useful.

However, during the programming day I get quite a lot of odd behaviour
and Excel crashes. I am wondering wether or not I am missing something
basic in my approach. In fact Excel crashes so often I have also
written some basic VBA code to export all my modules out to text files,
delete them from the work book, then re-import them afterwards. This
process does seem to fix most problems but eventually new ones appear.

The most recent is a line of code 'Set v_MyClassA = new clsMyClassA'
this actually calls the Class_Initialize of clsMyClassB. Again I
exported all the modules then re-imported them and it has now fixed the
problem. But why, why, why !!!!

I would appreciate it anybody could share their experience and perhaps
highlight a basic problem in my approach.


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
Cell change event causing EXCEL to crash Ashish Excel Worksheet Functions 3 January 9th 09 04:01 AM
Conditional formatting causing Excel to crash No Name Excel Discussion (Misc queries) 3 October 10th 08 03:35 PM
Add-in / xla causing random wierd GPF / crash Terry Aney Excel Programming 2 March 10th 06 04:23 AM
Charts causing program to crash Fysh Charts and Charting in Excel 1 December 16th 04 10:12 PM
Problem with code causing Excel '97 to crash Pozzo[_6_] Excel Programming 0 June 16th 04 08:19 PM


All times are GMT +1. The time now is 10:42 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"