Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.scripting.vbscript
external usenet poster
 
Posts: 26
Default Gurus: What's wrong with this code?

Hi,

I've been over and over it, and I can't find anything wrong. But it doesn't
work. It crashes Excel every time. I got it from a smart guy named Chip
Pearson (thank you Chip). To be specific, I added the variables inside the
named "String" arguments, but it didn't work before I did that either. It
*almost* works, then crashes...

' Insert SelectionChange event procedure
With
ActiveWorkbook.VBProject.VBComponents(ActiveWorkbo ok.Worksheets("Contents").
CodeName).CodeModule
.InsertLines Line:=.CreateEventProc("SelectionChange","Workshee t") + 1,
_
String:="If Not Intersect(Target, Range(""" & nextCell & """)) Is
Nothing Then" & VbCrLF & _
" Charts(""" & chartName & """).Activate" & VbCrLF & _
"End If"
End With


Any ideas?

Thank you,

Robert Stober


  #2   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.scripting.vbscript
external usenet poster
 
Posts: 27,285
Default Gurus: What's wrong with this code?

Sub Tester1()
With ActiveWorkbook.VBProject.VBComponents( _
ActiveWorkbook.Worksheets("Contents"). _
CodeName).CodeModule
.InsertLines Line:=.CreateEventProc( _
"SelectionChange", "Worksheet") + 1, _
String:= _
"If Not Intersect(Target, Range(""B2""))" & _
" Is Nothing Then" & vbCrLf & _
" Charts(""Chart1"").Activate" & vbCrLf & _
"End If"
End With
End Sub


Worked fine for me.

--
Regards,
Tom Ogilvy

Robert Stober wrote in message
...
Hi,

I've been over and over it, and I can't find anything wrong. But it

doesn't
work. It crashes Excel every time. I got it from a smart guy named Chip
Pearson (thank you Chip). To be specific, I added the variables inside the
named "String" arguments, but it didn't work before I did that either. It
*almost* works, then crashes...

' Insert SelectionChange event procedure
With

ActiveWorkbook.VBProject.VBComponents(ActiveWorkbo ok.Worksheets("Contents").
CodeName).CodeModule
.InsertLines Line:=.CreateEventProc("SelectionChange","Workshee t") +

1,
_
String:="If Not Intersect(Target, Range(""" & nextCell & """)) Is
Nothing Then" & VbCrLF & _
" Charts(""" & chartName & """).Activate" & VbCrLF & _
"End If"
End With


Any ideas?

Thank you,

Robert Stober




  #3   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.scripting.vbscript
external usenet poster
 
Posts: 26
Default Gurus: What's wrong with this code?

Tom,

Would it make any difference if this code was inside a macro that was called
from within a workbook_open event procedure? What I mean is that I have a
workbook_open procedure that calls a "CreateCharts" macro and this code is
in that macro. Do you think it would work in that situation? That's my
situation, and it's not working. What's more, even when I put in a stop
before this block, the block still runs and Excel still crashes...

Thank you,

Robert

"Tom Ogilvy" wrote in message
...
Sub Tester1()
With ActiveWorkbook.VBProject.VBComponents( _
ActiveWorkbook.Worksheets("Contents"). _
CodeName).CodeModule
.InsertLines Line:=.CreateEventProc( _
"SelectionChange", "Worksheet") + 1, _
String:= _
"If Not Intersect(Target, Range(""B2""))" & _
" Is Nothing Then" & vbCrLf & _
" Charts(""Chart1"").Activate" & vbCrLf & _
"End If"
End With
End Sub


Worked fine for me.

--
Regards,
Tom Ogilvy

Robert Stober wrote in message
...
Hi,

I've been over and over it, and I can't find anything wrong. But it

doesn't
work. It crashes Excel every time. I got it from a smart guy named Chip
Pearson (thank you Chip). To be specific, I added the variables inside

the
named "String" arguments, but it didn't work before I did that either.

It
*almost* works, then crashes...

' Insert SelectionChange event procedure
With


ActiveWorkbook.VBProject.VBComponents(ActiveWorkbo ok.Worksheets("Contents").
CodeName).CodeModule
.InsertLines Line:=.CreateEventProc("SelectionChange","Workshee t") +

1,
_
String:="If Not Intersect(Target, Range(""" & nextCell & """)) Is
Nothing Then" & VbCrLF & _
" Charts(""" & chartName & """).Activate" & VbCrLF & _
"End If"
End With


Any ideas?

Thank you,

Robert Stober






  #4   Report Post  
Posted to microsoft.public.excel.programming,microsoft.public.scripting.vbscript
external usenet poster
 
Posts: 27,285
Default Gurus: What's wrong with this code?

Responded to private email.

--
Regards,
Tom Ogilvy

"Robert Stober" wrote in message
...
Tom,

Would it make any difference if this code was inside a macro that was

called
from within a workbook_open event procedure? What I mean is that I have a
workbook_open procedure that calls a "CreateCharts" macro and this code is
in that macro. Do you think it would work in that situation? That's my
situation, and it's not working. What's more, even when I put in a stop
before this block, the block still runs and Excel still crashes...

Thank you,

Robert

"Tom Ogilvy" wrote in message
...
Sub Tester1()
With ActiveWorkbook.VBProject.VBComponents( _
ActiveWorkbook.Worksheets("Contents"). _
CodeName).CodeModule
.InsertLines Line:=.CreateEventProc( _
"SelectionChange", "Worksheet") + 1, _
String:= _
"If Not Intersect(Target, Range(""B2""))" & _
" Is Nothing Then" & vbCrLf & _
" Charts(""Chart1"").Activate" & vbCrLf & _
"End If"
End With
End Sub


Worked fine for me.

--
Regards,
Tom Ogilvy

Robert Stober wrote in message
...
Hi,

I've been over and over it, and I can't find anything wrong. But it

doesn't
work. It crashes Excel every time. I got it from a smart guy named

Chip
Pearson (thank you Chip). To be specific, I added the variables inside

the
named "String" arguments, but it didn't work before I did that either.

It
*almost* works, then crashes...

' Insert SelectionChange event procedure
With



ActiveWorkbook.VBProject.VBComponents(ActiveWorkbo ok.Worksheets("Contents").
CodeName).CodeModule
.InsertLines Line:=.CreateEventProc("SelectionChange","Workshee t")

+
1,
_
String:="If Not Intersect(Target, Range(""" & nextCell & """)) Is
Nothing Then" & VbCrLF & _
" Charts(""" & chartName & """).Activate" & VbCrLF & _
"End If"
End With


Any ideas?

Thank you,

Robert Stober








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
What is wrong with this code? Ayo Excel Discussion (Misc queries) 14 June 10th 08 03:09 AM
What is wrong with this code? jlclyde Excel Discussion (Misc queries) 5 January 9th 08 05:12 PM
What is wrong with the code? Eric Excel Discussion (Misc queries) 2 September 13th 07 10:36 AM
Can someone tell me what is wrong with this code? Ant Excel Discussion (Misc queries) 8 November 14th 05 02:53 PM
Is something wrong with the code Patrick Molloy[_3_] Excel Programming 1 July 15th 03 08:28 AM


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

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"