B
Brad Carman
I have a subroutine that is called from an Autpen subroutine that is shown
below. I have narrowed it down to this code as being the reason for excel
crashing on startup. Excel recoginizes that my Addin is the reason for the
problem and askes if I want to disable it. When that is done Excel starts
just fine. When I go to tools>addins.. and start my Addin up everything runs
fine, no errors are encountered. So why does this code create an error when
excel is starting as compared to after it has finished booting up? Thanks
for any help!! Here is my code...
Sub CreateRightClick()
Dim btn As CommandBarButton
Dim btn2 As CommandBarButton
Dim barArray As Variant
Dim i
barArray = Array("List Range Popup", "Cell", "Column", "Row")
For i = LBound(barArray) To UBound(barArray)
With Application.CommandBars(barArray(i))
.Reset
Set btn = .Controls.Add(Temporary:=True)
btn.BeginGroup = True
btn.Caption = "Apply Throughout"
btn.OnAction = "ApplyThroughout"
btn.FaceId = 201
Set btn2 = .Controls.Add(Temporary:=True)
btn2.Caption = "Calculate Cells"
btn2.OnAction = "ReCalcHighlighted"
btn2.FaceId = 202
End With
Set btn = Nothing
Set btn2 = Nothing
Next i
End Sub
below. I have narrowed it down to this code as being the reason for excel
crashing on startup. Excel recoginizes that my Addin is the reason for the
problem and askes if I want to disable it. When that is done Excel starts
just fine. When I go to tools>addins.. and start my Addin up everything runs
fine, no errors are encountered. So why does this code create an error when
excel is starting as compared to after it has finished booting up? Thanks
for any help!! Here is my code...
Sub CreateRightClick()
Dim btn As CommandBarButton
Dim btn2 As CommandBarButton
Dim barArray As Variant
Dim i
barArray = Array("List Range Popup", "Cell", "Column", "Row")
For i = LBound(barArray) To UBound(barArray)
With Application.CommandBars(barArray(i))
.Reset
Set btn = .Controls.Add(Temporary:=True)
btn.BeginGroup = True
btn.Caption = "Apply Throughout"
btn.OnAction = "ApplyThroughout"
btn.FaceId = 201
Set btn2 = .Controls.Add(Temporary:=True)
btn2.Caption = "Calculate Cells"
btn2.OnAction = "ReCalcHighlighted"
btn2.FaceId = 202
End With
Set btn = Nothing
Set btn2 = Nothing
Next i
End Sub