Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Error Message When running code but not stepping through it.

I'm attempting to use VBA to add a Command Button to a Worksheet. When I step
through the code (using F8) it works fine. However, when I simply try to run
it, Excel crashes and I get the error:

The instruction at '0x650e7624' referenced memory at '0x053c831c'. The
memory could not be read.

Any idea what is going on?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Error Message When running code but not stepping through it.

Hi Jared

If you are using Excel 97 then try this

Try to Change the takefocusonclick property to false of the button
This is a bug in Excel 97


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jared" wrote in message ...
I'm attempting to use VBA to add a Command Button to a Worksheet. When I step
through the code (using F8) it works fine. However, when I simply try to run
it, Excel crashes and I get the error:

The instruction at '0x650e7624' referenced memory at '0x053c831c'. The
memory could not be read.

Any idea what is going on?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Error Message When running code but not stepping through it.

Ron,

I'm using Excel 2002. I should have wrote that in the first post. Sorry.

"Ron de Bruin" wrote:

Hi Jared

If you are using Excel 97 then try this

Try to Change the takefocusonclick property to false of the button
This is a bug in Excel 97


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jared" wrote in message ...
I'm attempting to use VBA to add a Command Button to a Worksheet. When I step
through the code (using F8) it works fine. However, when I simply try to run
it, Excel crashes and I get the error:

The instruction at '0x650e7624' referenced memory at '0x053c831c'. The
memory could not be read.

Any idea what is going on?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Error Message When running code but not stepping through it.

I don't see your code but this is working for me for Sheet1

Sub test()
Dim WS As Worksheet
Dim Btn As OLEObject
Set WS = ThisWorkbook.Worksheets("Sheet1")
With WS
Set Btn = .OLEObjects.Add(ClassType:="Forms.CommandButton.1" , _
Left:=.Range("C3").Left, Top:=.Range("C3").Top, _
Width:=100, Height:=30)
End With
Btn.Object.Caption = "Click Me"
Btn.Name = "YourButton"
With ThisWorkbook.VBProject.VBComponents(WS.CodeName).C odeModule
.InsertLines .CreateEventProc("Click", Btn.Name) + 1, _
vbTab & "If Range(""A1"").Value 0 Then " & vbCrLf & _
vbTab & vbTab & "Msgbox ""Hi""" & vbCrLf & _
vbTab & "End If"
End With
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jared" wrote in message ...
Ron,

I'm using Excel 2002. I should have wrote that in the first post. Sorry.

"Ron de Bruin" wrote:

Hi Jared

If you are using Excel 97 then try this

Try to Change the takefocusonclick property to false of the button
This is a bug in Excel 97


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jared" wrote in message ...
I'm attempting to use VBA to add a Command Button to a Worksheet. When I step
through the code (using F8) it works fine. However, when I simply try to run
it, Excel crashes and I get the error:

The instruction at '0x650e7624' referenced memory at '0x053c831c'. The
memory could not be read.

Any idea what is going on?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 109
Default Error Message When running code but not stepping through it.

I don't know why, but when I changed the location of it in my code it worked
fine.

"Ron de Bruin" wrote:

I don't see your code but this is working for me for Sheet1

Sub test()
Dim WS As Worksheet
Dim Btn As OLEObject
Set WS = ThisWorkbook.Worksheets("Sheet1")
With WS
Set Btn = .OLEObjects.Add(ClassType:="Forms.CommandButton.1" , _
Left:=.Range("C3").Left, Top:=.Range("C3").Top, _
Width:=100, Height:=30)
End With
Btn.Object.Caption = "Click Me"
Btn.Name = "YourButton"
With ThisWorkbook.VBProject.VBComponents(WS.CodeName).C odeModule
.InsertLines .CreateEventProc("Click", Btn.Name) + 1, _
vbTab & "If Range(""A1"").Value 0 Then " & vbCrLf & _
vbTab & vbTab & "Msgbox ""Hi""" & vbCrLf & _
vbTab & "End If"
End With
End Sub




--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jared" wrote in message ...
Ron,

I'm using Excel 2002. I should have wrote that in the first post. Sorry.

"Ron de Bruin" wrote:

Hi Jared

If you are using Excel 97 then try this

Try to Change the takefocusonclick property to false of the button
This is a bug in Excel 97


--
Regards Ron de Bruin
http://www.rondebruin.nl


"Jared" wrote in message ...
I'm attempting to use VBA to add a Command Button to a Worksheet. When I step
through the code (using F8) it works fine. However, when I simply try to run
it, Excel crashes and I get the error:

The instruction at '0x650e7624' referenced memory at '0x053c831c'. The
memory could not be read.

Any idea what is going on?






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
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 7 March 7th 05 06:29 PM
Error trapped only while stepping through the code - Not triggered when run Jeff Excel Discussion (Misc queries) 0 February 28th 05 06:26 PM
VBA Code works by stepping through, not by running JbL Excel Programming 7 November 4th 04 02:49 PM
Error message When running Macros on MS excel 2002 Kosmos2040 Excel Programming 2 April 30th 04 05:56 PM
Stepping through code gives different results than running it! Simon White Excel Programming 2 November 13th 03 09:44 PM


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