LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default "can't enter break mode" error

Trying to learn how to use vba to write vba code. Copied this code from
Walkenbach's book to watch how it runs, but when i try to run it, I get the
error message "cant' enter break mode" on
Set NewButton = NewSheet.OLEObjects.Add("Forms.CommandButton.1")

Sub AddSheetAndButton()
Dim NewSheet As Worksheet
Dim Newbutton As OLEObject
Dim Code As String
Dim NextLine As Integer

'Add the sheet
Set NewSheet = Sheets.Add

'Add a CommandButton
Set Newbutton = NewSheet.OLEObjects.Add("Forms.CommandButton.1")
With Newbutton
.Left = 4
.Top = 4
.Width = 100
.Height = 24
.Object.Caption = "Return to Sheet1"
End With

'Add the event handler code
Code = "Sub CommandButton1_Click()" & vbCrLf
Code = Code & " On Error Resume Next" & vbCrLf
Code = Code & " Sheets(""Sheet1"").Activate" & vbCrLf
Code = Code & " If Err <0 Then" & vbCrLf
Code = Code & " MsgBox ""Cannot activete Sheet1.""" & vbCrLf
Code = Code & " End If" & vbCrLf
Code = Code & "End Sub"

With ActiveWorkbook.VBProject.VBComponents(NewSheet.Nam e).CodeModule
NextLine = .CountOfLines + 1
.InsertLines NextLine, Code
End With
End Sub

Have not set any breakpoints in the module.
Any ideas on what could be triggering this?

Tx
 
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
Any ideas "can't enter break mode at this time" error gone amok ArielMalek Excel Programming 1 July 12th 08 08:15 AM
"can't enter break mode at this time" message when adding a projectreference dbKemp Excel Programming 0 January 30th 08 03:12 PM
"Can't enter break mode at this time" error coming up robs3131 Excel Programming 5 August 3rd 07 09:10 AM
"Can't enter break mode at this time" Paul T. Excel Programming 5 August 25th 06 10:57 PM
"Can't Enter Break Mode"? CWillis Excel Discussion (Misc queries) 2 May 31st 06 09:17 PM


All times are GMT +1. The time now is 06:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"