everytime i open my workbook this error pops up:-
run time error- 1004
application defined or object defined error
when i debug it, it takes me to the bold line i marked in red color and says :-
Cant execute code in break mode...
the code pops up the userform whenever a selected shape is moved from certain position to another. Positions based on column number.
code is saved in this workbook
please help!! I dont know what is wrong
run time error- 1004
application defined or object defined error
when i debug it, it takes me to the bold line i marked in red color and says :-
Cant execute code in break mode...
the code pops up the userform whenever a selected shape is moved from certain position to another. Positions based on column number.
code is saved in this workbook
Rich (BB code):
Option Explicit
Private WithEvents CmbrsEvent As CommandBars
Private Const TargetSheet As String = "Tasks" ' <== change sheet as required
Private Sub Workbook_Open()
Dim oShp As Shape
Application.CommandBars.FindControl(id:=549).Execute ' To snap the shapes to grid
Call UpdateColor 'Updatecolor has to be called ones to start the timer
For Each oShp In Sheets(TargetSheet).Shapes
oShp.AlternativeText = oShp.Left & "*" & oShp.TopLeftCell.column
Next
Set CmbrsEvent = Application.CommandBars
End Sub
'to show Userform when shape is moved from InWork lane to Closed lane
Private Sub CmbrsEvent_OnUpdate()
Dim ar() As String
On Error Resume Next
With Sheets(TargetSheet).Shapes(Selection.name)
If TypeName(Selection) <> "Range" And Selection.Parent Is Sheets(TargetSheet) Then
ar = Split(.AlternativeText, "*")
If ar(0) <> CStr(.Left) And ar(1) <> CStr(.TopLeftCell.column) And ar(1) = "8" Then
If .TopLeftCell.column = 15 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 16 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 17 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 18 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
End If
ElseIf ar(0) <> CStr(.Left) And ar(1) <> CStr(.TopLeftCell.column) And ar(1) = "9" Then
If .TopLeftCell.column = 15 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 16 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 17 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 18 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
End If
ElseIf ar(0) <> CStr(.Left) And ar(1) <> CStr(.TopLeftCell.column) And ar(1) = "10" Then
If .TopLeftCell.column = 15 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 16 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 17 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 18 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
End If
ElseIf ar(0) <> CStr(.Left) And ar(1) <> CStr(.TopLeftCell.column) And ar(1) = "11" Then
If .TopLeftCell.column = 15 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 16 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 17 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
ElseIf .TopLeftCell.column = 18 Then
Application.OnTime Now, Me.CodeName & ".ShowForm"
End If
End If
End If
.AlternativeText = .Left & "*" & .TopLeftCell.column
End With
End Sub
Private Sub ShowForm()
UserForm1.Label2.Caption = Selection.ShapeRange.TextFrame2.TextRange.Characters.Text
UserForm1.Show
End Sub
please help!! I dont know what is wrong