PC Review


Reply
Thread Tools Rate Thread

How can this crash Excel?

 
 
RB Smissaert
Guest
Posts: n/a
 
      29th May 2010
In a loaded .xla add-in I have the following code in the ThisWorkbook
module:

Option Explicit
Private WithEvents xlApp As Excel.Application

Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target As
Range)
On Error GoTo ERROROUT
If Len(Target.Name.Name) > 10 Then
Application.StatusBar = Space(8) & Target.Name.Name
Else
Application.StatusBar = False
End If
Exit Sub
ERROROUT:
Application.StatusBar = False
End Sub

This code runs fine on many machines, but on one particular machine only
(Excel 2003, Win XP) the line
If Len(Target.Name.Name) > 10 Then
crashes Excel when there is a filter in the sheet.

What possibly could be the trouble here?
I can't reproduce this at all on my machine, so difficult to unravel this
problem, but maybe somebody
has an idea.

RBS

 
Reply With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      29th May 2010
That workbook has the right error handling setting, that is Break on
unhandled errors.
It is not the name of the sheet, but the name of the selected range.
Baffling me this.

RBS


"joel" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> check the error setting in VBA menu Tools - Options - general - Error
> trapping.
>
> It may be that the book that crashes has a different setting.
>
> I think your code really wants to get the name of the sheet and I would
> change the code to this
>
> from:
> If Len(Target.Name.Name) > 10 Then
>
> to:
> If Len(Target.parent.Name) > 10 Then
>
>
> The parent of a cell or range opn a worksheet is the worksheet.
>
>
> --
> joel
> ------------------------------------------------------------------------
> joel's Profile: http://www.thecodecage.com/forumz/member.php?u=229
> View this thread:
> http://www.thecodecage.com/forumz/sh...d.php?t=206051
>
> http://www.thecodecage.com/forumz
>


 
Reply With Quote
 
Peter T
Guest
Posts: n/a
 
      31st May 2010
Hi Bart,

Nothing obvious springs to mind. A Sheet with an autofilter (or sheet that
has had an autofilter) will include a worksheet level name like this

Sheet1!_FilterDatabase

If user selects the cells with the dropdown filters that's what would be
returned with
Target.Name.Name

However that shouldn't cause a problem. Best thing would be to ask the user
to send you a copy of the problematic workbook, stripped down with just
enough to reproduce the problem.

Regards,
Peter T


"RB Smissaert" <(E-Mail Removed)> wrote in message
news:%23mmZ2O0$(E-Mail Removed)...
> In a loaded .xla add-in I have the following code in the ThisWorkbook
> module:
>
> Option Explicit
> Private WithEvents xlApp As Excel.Application
>
> Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target As
> Range)
> On Error GoTo ERROROUT
> If Len(Target.Name.Name) > 10 Then
> Application.StatusBar = Space(8) & Target.Name.Name
> Else
> Application.StatusBar = False
> End If
> Exit Sub
> ERROROUT:
> Application.StatusBar = False
> End Sub
>
> This code runs fine on many machines, but on one particular machine only
> (Excel 2003, Win XP) the line
> If Len(Target.Name.Name) > 10 Then
> crashes Excel when there is a filter in the sheet.
>
> What possibly could be the trouble here?
> I can't reproduce this at all on my machine, so difficult to unravel this
> problem, but maybe somebody
> has an idea.
>
> RBS
>



 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      31st May 2010
Hi Peter,

I got the workbook, but I couldn't reproduce this problem.
The only purpose of that code was to show the selected
range name in the statusbar if it possibly wouldn't show
fully in the name box (at the top left).
So, not really essential and I have thrown that code out now.
I know in fact a way (with the API) to widen that name
box and that is a better way.

RBS


"Peter T" <peter_t@discussions> wrote in message
news:(E-Mail Removed)...
> Hi Bart,
>
> Nothing obvious springs to mind. A Sheet with an autofilter (or sheet that
> has had an autofilter) will include a worksheet level name like this
>
> Sheet1!_FilterDatabase
>
> If user selects the cells with the dropdown filters that's what would be
> returned with
> Target.Name.Name
>
> However that shouldn't cause a problem. Best thing would be to ask the
> user to send you a copy of the problematic workbook, stripped down with
> just enough to reproduce the problem.
>
> Regards,
> Peter T
>
>
> "RB Smissaert" <(E-Mail Removed)> wrote in message
> news:%23mmZ2O0$(E-Mail Removed)...
>> In a loaded .xla add-in I have the following code in the ThisWorkbook
>> module:
>>
>> Option Explicit
>> Private WithEvents xlApp As Excel.Application
>>
>> Private Sub xlApp_SheetSelectionChange(ByVal Sh As Object, ByVal Target
>> As Range)
>> On Error GoTo ERROROUT
>> If Len(Target.Name.Name) > 10 Then
>> Application.StatusBar = Space(8) & Target.Name.Name
>> Else
>> Application.StatusBar = False
>> End If
>> Exit Sub
>> ERROROUT:
>> Application.StatusBar = False
>> End Sub
>>
>> This code runs fine on many machines, but on one particular machine only
>> (Excel 2003, Win XP) the line
>> If Len(Target.Name.Name) > 10 Then
>> crashes Excel when there is a filter in the sheet.
>>
>> What possibly could be the trouble here?
>> I can't reproduce this at all on my machine, so difficult to unravel this
>> problem, but maybe somebody
>> has an idea.
>>
>> RBS
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel 2007 crash when saving a specific file as excel 2003 format Frustrated Microsoft Excel Crashes 0 18th Jul 2008 12:44 PM
Excel 2003 Additional Workbooks After Excel Crash =?Utf-8?B?Y29tcG91bmQ=?= Microsoft Excel Programming 1 20th Jun 2007 04:48 PM
Excel VBA Form crash,Mac OS X, Excel 2004 for Mac, version 11.1 =?Utf-8?B?V2lsbGlhbSBhdCBDb3JuZWxs?= Microsoft Excel Crashes 0 7th Jan 2005 04:05 PM
Unknown crashing in Excel 2000 - doesn't crash in Excel XP. Please help! winjer23 Microsoft Excel Discussion 6 25th Aug 2004 10:03 AM
Crystal report in Excel format makes Excel crash =?Utf-8?B?T0c=?= Microsoft Excel Crashes 0 30th Oct 2003 12:16 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:38 PM.