Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Macro limitation

Hi,
I have an Excel file that seems too big but only 2mb. The file cannot be
opened after saving it. I thought it was a problem with the module code but
seems to be an error with vba code size?
1) If I remove the vba code password, all word good!
2) If I remove a selected module, all work good.
3) If I remove a 3 others modules at the same time, all work good.
These 3 solutions are completly independant. Is it possible that I have
reach some excel limitation ?
Thanks!
Alex
Note: The program contains 19 modules, 2 forms and a macro that is opened at
the opening of the file. All work very good when the file is open. I really
don't know how to debug it.
--
Alex St-Pierre
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Macro limitation

The logical suspect would be the macro that is running when you open the
workbook. Try either simply removing that macro code from it all and see how
things go. If it opens without that macro, then examine that macro closely
to see what it is doing - or put a STOP statement right at the beginning of
the code and open the workbook and then use [F8] to single step thru it to
see where it bombs.

If you still have troubles, post the code and people will try to help you
with it.

"Alex St-Pierre" wrote:

Hi,
I have an Excel file that seems too big but only 2mb. The file cannot be
opened after saving it. I thought it was a problem with the module code but
seems to be an error with vba code size?
1) If I remove the vba code password, all word good!
2) If I remove a selected module, all work good.
3) If I remove a 3 others modules at the same time, all work good.
These 3 solutions are completly independant. Is it possible that I have
reach some excel limitation ?
Thanks!
Alex
Note: The program contains 19 modules, 2 forms and a macro that is opened at
the opening of the file. All work very good when the file is open. I really
don't know how to debug it.
--
Alex St-Pierre

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 169
Default Macro limitation

Thanks !
I don't know how to put a stop.
As you said, I have check the Private Sub Workbook_Open()
Set refs = ThisWorkbook.VBProject.References
If refs Is Nothing Then
MsgBox "The program cannot access your VBA code."
iCloseExcel = 1
Exit Sub
End If
What I found is that iCloseExcel = 1 is a Global Variable that is defined
inside a module. (Global i as integer). I don't know why but...
1) if I remove this line, the program open correctly.
2) if I remove the module that contains Global iCloseExcel As Integer, the
program work correctly
3) if I remove the password of the vba code, the program work correctly (can
initiliaze Global iCloseExcel as integer before saying iCloseExcel = 1 ???
4) if I use Excel 2002, the program work better than with version 2003
5) I used this line for a while and never had problem with password. The
only thing I can say it that the module are bigger and this is why it create
a problem with the global variable. If I removed a lot of module and let the
module with Global iCloseExcel as integer, all work good !!!
Before having problem with that, the file size was 2.1mo, after having the
problem, I opened the program with Excel 2002 and save it. The program takes
only 0.9mo. Does I loose informations or what?
Thanks!
Alex
--
Alex St-Pierre


"JLatham" wrote:

The logical suspect would be the macro that is running when you open the
workbook. Try either simply removing that macro code from it all and see how
things go. If it opens without that macro, then examine that macro closely
to see what it is doing - or put a STOP statement right at the beginning of
the code and open the workbook and then use [F8] to single step thru it to
see where it bombs.

If you still have troubles, post the code and people will try to help you
with it.

"Alex St-Pierre" wrote:

Hi,
I have an Excel file that seems too big but only 2mb. The file cannot be
opened after saving it. I thought it was a problem with the module code but
seems to be an error with vba code size?
1) If I remove the vba code password, all word good!
2) If I remove a selected module, all work good.
3) If I remove a 3 others modules at the same time, all work good.
These 3 solutions are completly independant. Is it possible that I have
reach some excel limitation ?
Thanks!
Alex
Note: The program contains 19 modules, 2 forms and a macro that is opened at
the opening of the file. All work very good when the file is open. I really
don't know how to debug it.
--
Alex St-Pierre

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Macro limitation

To put a stop statement in the code, you just go to the end of an existing
line and hit the [Enter] key to insert a new line and simply type
Stop
and hit the [Enter] key again. When the program gets to that point, it will
enter into debug mode with the Stop highlighted. Then you can press the [F8]
key to go to the next step in the code and repeat pressing [F8] for as long
as you care to follow it to see what is happening. But I believe I know
what's happening: you have the VB Project protected with a password, so the
line that reads
Set refs = ThisWorkbook.VBProject.References
is unable to get into the VBProject because of the password keeping it out.
So in the next line 'refs' is Nothing, so the global iCloseExel is set to 1
at that point and something else somewhere is checking that value and when it
sees that it is 1, it is closing Excel.
It seems that the logical thing to do here is not protect the VBProject with
a password unless there is some real serious need to keep people from seeing
the code. The question is why the program needs to be able to see the VBA
code anyhow, unless it is trying to determine somewhere else whether or not a
particular reference to a library is available or not. If that is the case,
then it can probably be rewritten to test for that in some other fashion.
There are too many "why" and "what" questions to make a real recommendation.

If you want to just ignore this whole situation, which may result in the
workbook not working for someone else, you could simply remove the
iCloseExcel = 1
statement from the code there. You'd still get an alert that things may not
be quite right, but iCloseExel would remain 0 when the routine ended and
probably not trigger closing the application later.

As for the file shrinkage, I doubt that you've lost any data. More than
likely the used at some time in the past, but no longer used areas on
worksheets have gotten marked as unused now, which is a good thing.


"Alex St-Pierre" wrote:

Thanks !
I don't know how to put a stop.
As you said, I have check the Private Sub Workbook_Open()
Set refs = ThisWorkbook.VBProject.References
If refs Is Nothing Then
MsgBox "The program cannot access your VBA code."
iCloseExcel = 1
Exit Sub
End If
What I found is that iCloseExcel = 1 is a Global Variable that is defined
inside a module. (Global i as integer). I don't know why but...
1) if I remove this line, the program open correctly.
2) if I remove the module that contains Global iCloseExcel As Integer, the
program work correctly
3) if I remove the password of the vba code, the program work correctly (can
initiliaze Global iCloseExcel as integer before saying iCloseExcel = 1 ???
4) if I use Excel 2002, the program work better than with version 2003
5) I used this line for a while and never had problem with password. The
only thing I can say it that the module are bigger and this is why it create
a problem with the global variable. If I removed a lot of module and let the
module with Global iCloseExcel as integer, all work good !!!
Before having problem with that, the file size was 2.1mo, after having the
problem, I opened the program with Excel 2002 and save it. The program takes
only 0.9mo. Does I loose informations or what?
Thanks!
Alex
--
Alex St-Pierre


"JLatham" wrote:

The logical suspect would be the macro that is running when you open the
workbook. Try either simply removing that macro code from it all and see how
things go. If it opens without that macro, then examine that macro closely
to see what it is doing - or put a STOP statement right at the beginning of
the code and open the workbook and then use [F8] to single step thru it to
see where it bombs.

If you still have troubles, post the code and people will try to help you
with it.

"Alex St-Pierre" wrote:

Hi,
I have an Excel file that seems too big but only 2mb. The file cannot be
opened after saving it. I thought it was a problem with the module code but
seems to be an error with vba code size?
1) If I remove the vba code password, all word good!
2) If I remove a selected module, all work good.
3) If I remove a 3 others modules at the same time, all work good.
These 3 solutions are completly independant. Is it possible that I have
reach some excel limitation ?
Thanks!
Alex
Note: The program contains 19 modules, 2 forms and a macro that is opened at
the opening of the file. All work very good when the file is open. I really
don't know how to debug it.
--
Alex St-Pierre

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,365
Default Macro limitation

Oh, the reason that a Global or Public variable is declared in that manner is
so that any code in any part of the application (any of your code modules or
the routines within them) can see its value. It gets complicated to explain
all of the rules, but lets just say that if it were not a Global variable,
then even though it was declared (as a local variable with a statement like
Dim iCloseExcel As Integer) then another module or code segment somewhere
else in the program would not be able to tell what it's value was set to by
the _Open Event.

"JLatham" wrote:

The logical suspect would be the macro that is running when you open the
workbook. Try either simply removing that macro code from it all and see how
things go. If it opens without that macro, then examine that macro closely
to see what it is doing - or put a STOP statement right at the beginning of
the code and open the workbook and then use [F8] to single step thru it to
see where it bombs.

If you still have troubles, post the code and people will try to help you
with it.

"Alex St-Pierre" wrote:

Hi,
I have an Excel file that seems too big but only 2mb. The file cannot be
opened after saving it. I thought it was a problem with the module code but
seems to be an error with vba code size?
1) If I remove the vba code password, all word good!
2) If I remove a selected module, all work good.
3) If I remove a 3 others modules at the same time, all work good.
These 3 solutions are completly independant. Is it possible that I have
reach some excel limitation ?
Thanks!
Alex
Note: The program contains 19 modules, 2 forms and a macro that is opened at
the opening of the file. All work very good when the file is open. I really
don't know how to debug it.
--
Alex St-Pierre



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
Row Limitation Atom Smasher Excel Discussion (Misc queries) 4 July 17th 06 07:59 PM
Way around row limitation mrwawa Excel Discussion (Misc queries) 4 June 29th 06 08:46 PM
DDE limitation? Julian Cox Excel Programming 0 August 24th 04 02:02 PM
IF Limitation? Michael168[_88_] Excel Programming 3 June 7th 04 06:42 PM
automated macro's? and macro limitation to a worksheet FAM THEUWS Excel Programming 1 November 5th 03 10:23 PM


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

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

About Us

"It's about Microsoft Excel"