gravanoc
Active Member
- Joined
- Oct 20, 2015
- Messages
- 351
- Office Version
- 365
- Platform
- Windows
- Mobile
I have a situation where this code breaks Excel:
It was prior to the 3rd crash that I identified which line of code was responsible, setting a variable referencing a form checkbox that has the above macro assigned to it. Normally,
this is fine on Windows Excel. I looked up Ron de Bruin's macexcel.com website, and an article on shapes infers that the Checkboxes collection is usable, so perhaps something else is wrong?
The other possibility is that Application.Caller is causing the problem. Any ideas?
Edit: changed the Dim chkBox as Object to "As CheckBox", since that is what it said when the crash happened.
VBA Code:
Sub ArchiveSheet()
Dim chkBox As CheckBox
Dim wks As Worksheet
Dim rngArchive As Range
Dim rngMessage As Range
Dim shtNo As Long, i As Long
Dim defVal(0 To 2) As Variant
Call EventStop
Set wks = ActiveSheet
Set chkBox = wks.CheckBoxes(Application.Caller) ' Crashes to desktop here
. . . more code
It was prior to the 3rd crash that I identified which line of code was responsible, setting a variable referencing a form checkbox that has the above macro assigned to it. Normally,
this is fine on Windows Excel. I looked up Ron de Bruin's macexcel.com website, and an article on shapes infers that the Checkboxes collection is usable, so perhaps something else is wrong?
The other possibility is that Application.Caller is causing the problem. Any ideas?
Edit: changed the Dim chkBox as Object to "As CheckBox", since that is what it said when the crash happened.