ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   error traping (https://www.excelbanter.com/excel-programming/328351-error-traping.html)

Jim at Eagle

error traping
 
Sub WView(ViewNb)
Application.EnableEvents = False
On Error GoTo Gone
Select Case ViewNb
Case 1
With Application
'.WindowState = xlNormal
.Width = 680
.Height = 573
End With
Case 2
With Application
'.WindowState = xlNormal
.Width = 763
.Height = 573
End With
End Select
Gone:
Application.EnableEvents = True
End Sub
This wont work. The error message is displayed and error halts operation.
Looked everywhere and experimented with a lot of variations.
Thanks for your help.

--
Jim at Eagle

Patrick Molloy[_2_]

error traping
 
works fine. I used

Option Explicit
Sub tester()
WView 2
End Sub
Sub WView(ViewNb)

With Application
Select Case ViewNb
Case 1
.Width = 300
.Height = 573
Case 2
.Width = 900
.Height = 573
End Select
End With

End Sub


Have you got workbook protection set?


"Jim at Eagle" wrote:

Sub WView(ViewNb)
Application.EnableEvents = False
On Error GoTo Gone
Select Case ViewNb
Case 1
With Application
'.WindowState = xlNormal
.Width = 680
.Height = 573
End With
Case 2
With Application
'.WindowState = xlNormal
.Width = 763
.Height = 573
End With
End Select
Gone:
Application.EnableEvents = True
End Sub
This wont work. The error message is displayed and error halts operation.
Looked everywhere and experimented with a lot of variations.
Thanks for your help.

--
Jim at Eagle


Jim at Eagle

error traping
 
The problem is the error trap. If the workbook is started in xlMaximized then
a error occurs. I added WindowState = xlNormal to solve this problem (it's
commented out here just to crash the code on my machine for testing purpose).
However the code still fails on some computers. So I want to eliminate all
window size resize functionality from the procedures. I thought an error
operation would do this, but it doesnt work. My computer handles quite
nicely but Franks dont. I dont want to remove my uncle from my universe.

--
Jim at Eagle


"Patrick Molloy" wrote:

works fine. I used

Option Explicit
Sub tester()
WView 2
End Sub
Sub WView(ViewNb)

With Application
Select Case ViewNb
Case 1
.Width = 300
.Height = 573
Case 2
.Width = 900
.Height = 573
End Select
End With

End Sub


Have you got workbook protection set?


"Jim at Eagle" wrote:

Sub WView(ViewNb)
Application.EnableEvents = False
On Error GoTo Gone
Select Case ViewNb
Case 1
With Application
'.WindowState = xlNormal
.Width = 680
.Height = 573
End With
Case 2
With Application
'.WindowState = xlNormal
.Width = 763
.Height = 573
End With
End Select
Gone:
Application.EnableEvents = True
End Sub
This wont work. The error message is displayed and error halts operation.
Looked everywhere and experimented with a lot of variations.
Thanks for your help.

--
Jim at Eagle


Robert Bruce[_2_]

error traping
 
Jim at Eagle wrote:
The problem is the error trap. If the workbook is started in
xlMaximized then a error occurs. I added WindowState = xlNormal to
solve this problem (it's commented out here just to crash the code on
my machine for testing purpose). However the code still fails on some
computers. So I want to eliminate all window size resize
functionality from the procedures. I thought an error operation would
do this, but it doesn't work. My computer handles quite nicely but
Franks don't. I don't want to remove my uncle from my universe.


In the VBE go to Tools | Options and on the General tab, ensure that Error
Trapping is set to Break on Unhandled Errors.

Rob



Jim at Eagle

error traping
 
Rob is there a way to program in that setting so that strange computers use
spreadsheet?
--
Jim at Eagle


"Robert Bruce" wrote:

Jim at Eagle wrote:
The problem is the error trap. If the workbook is started in
xlMaximized then a error occurs. I added WindowState = xlNormal to
solve this problem (it's commented out here just to crash the code on
my machine for testing purpose). However the code still fails on some
computers. So I want to eliminate all window size resize
functionality from the procedures. I thought an error operation would
do this, but it doesn't work. My computer handles quite nicely but
Franks don't. I don't want to remove my uncle from my universe.


In the VBE go to Tools | Options and on the General tab, ensure that Error
Trapping is set to Break on Unhandled Errors.

Rob




Robert Bruce[_2_]

error traping
 
Jim at Eagle wrote:
Rob is there a way to program in that setting so that strange
computers use spreadsheet?

Jim at Eagle wrote:
<....

In the VBE go to Tools | Options and on the General tab, ensure that
Error Trapping is set to Break on Unhandled Errors.

Rob


No. There may be hacks using sendkeys and/or possibly setting a registry
value, but there is no direct way of doing this using either the Excel or
VBE object models. The good news is that once the setting is done it will
persist across subsequent Excel sessions (unless/until the user resets it,
of course). However, if the user is stuck with Excel 97, the setting does
*not* persist and defaults to Break in Class Module every time Excel starts.
This is the main reason I have never used class modules in Excel, but have
always built all of my business logic into VB6 dlls.

Rob



Tom Ogilvy

error traping
 
However, if the user is stuck with Excel 97, the setting does
*not* persist and defaults to Break in Class Module every time Excel

starts.


Must be the UK version. I have never noted this in Excel 97 (US)

Does it happen always, or only when the project contains a class module?

--
Regards,
Tom Ogilvy

"Robert Bruce" <rob@analytical-dynamicsdotcodotukay wrote in message
...
Jim at Eagle wrote:
Rob is there a way to program in that setting so that strange
computers use spreadsheet?

Jim at Eagle wrote:
<....
In the VBE go to Tools | Options and on the General tab, ensure that
Error Trapping is set to Break on Unhandled Errors.

Rob


No. There may be hacks using sendkeys and/or possibly setting a registry
value, but there is no direct way of doing this using either the Excel or
VBE object models. The good news is that once the setting is done it will
persist across subsequent Excel sessions (unless/until the user resets it,
of course). However, if the user is stuck with Excel 97, the setting does
*not* persist and defaults to Break in Class Module every time Excel

starts.
This is the main reason I have never used class modules in Excel, but have
always built all of my business logic into VB6 dlls.

Rob





Robert Bruce[_2_]

error traping
 
Roedd <<Tom Ogilvy wedi ysgrifennu:

However, if the user is stuck with Excel 97, the setting does
*not* persist and defaults to Break in Class Module every time Excel
starts.



Must be the UK version. I have never noted this in Excel 97 (US)

Does it happen always, or only when the project contains a class
module?


I thought this was well documented. A quick google-groups gives me:

http://tinyurl.com/abtty
http://tinyurl.com/cuolp
http://tinyurl.com/9v8vy
http://tinyurl.com/at7jf
http://tinyurl.com/ccgsc

etc...

--
Rob

http://www.asta51.dsl.pipex.com/webcam/

This message is copyright Robert Bruce and intended
for distribution only via NNTP.
Dissemination via third party Web forums with the
exception of Google Groups and Microsoft Communities
is strictly prohibited and may result in legal action.



Tom Ogilvy

error traping
 
It appears it only happens when the project contains a class - which is what
I asked.

Thanks.

--
Regards,
Tom Ogilvy

"Robert Bruce" <rob@analytical-dynamicsdotcodotukay wrote in message
...
Roedd <<Tom Ogilvy wedi ysgrifennu:

However, if the user is stuck with Excel 97, the setting does
*not* persist and defaults to Break in Class Module every time Excel
starts.



Must be the UK version. I have never noted this in Excel 97 (US)

Does it happen always, or only when the project contains a class
module?


I thought this was well documented. A quick google-groups gives me:

http://tinyurl.com/abtty
http://tinyurl.com/cuolp
http://tinyurl.com/9v8vy
http://tinyurl.com/at7jf
http://tinyurl.com/ccgsc

etc...

--
Rob

http://www.asta51.dsl.pipex.com/webcam/

This message is copyright Robert Bruce and intended
for distribution only via NNTP.
Dissemination via third party Web forums with the
exception of Google Groups and Microsoft Communities
is strictly prohibited and may result in legal action.





Robert Bruce[_2_]

error traping
 
Roedd <<Tom Ogilvy wedi ysgrifennu:

It appears it only happens when the project contains a class - which
is what I asked.



Actually Tom, the setting is application-wide and really doesn't concern
itself with the current (or indeed any other) project.

In any case, don't all projects contain at least one class module
(ThisWorkbook)? ;-)

--
Rob

http://www.asta51.dsl.pipex.com/webcam/

This message is copyright Robert Bruce and intended
for distribution only via NNTP.
Dissemination via third party Web forums with the
exception of Google Groups and Microsoft Communities
is strictly prohibited and may result in legal action.




All times are GMT +1. The time now is 02:53 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com