Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Error trapped only while stepping through the code - Not triggered when run | Excel Discussion (Misc queries) | |||
Error trapped only while stepping through the code - Not triggered when run | Excel Discussion (Misc queries) | |||
VBA Code works by stepping through, not by running | Excel Programming | |||
Error message When running Macros on MS excel 2002 | Excel Programming | |||
Stepping through code gives different results than running it! | Excel Programming |