ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   stubborn Excel crash when editing code with code, one solution (https://www.excelbanter.com/excel-programming/323618-stubborn-excel-crash-when-editing-code-code-one-solution.html)

Brian Murphy

stubborn Excel crash when editing code with code, one solution
 
Dear Group,

I've recently begun editing code with code, and I had been getting a great deal of crashes when doing this. When I searched the group archives I didn't really find anything that helped, but I have stumbled onto something that seems to have cured the crashes (at least for now).

I was doing something pretty straightforward. Writing a single Sub to a worksheet's codemodule, replacing it if a procedure by the same name was already there. Excel would crash after seeming to successfully complete the writing of the Sub, and then continuing on with the code that called this in the first place.

I was using an object variable for the CodeModule along with the ..DeleteLines and .InsertLines methods. After using .DeleteLines, re-Set-ting this object variable before calling .InsertLines cured the crashes.

I hope somebody finds this helpful,

Brian Murphy



All times are GMT +1. The time now is 03:15 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com