![]() |
Accessing VBProject causes the program to crash
I have a module that writes code to a worksheet..
I have checked "Trust access to Visual Basic Project. Excel crashes. Any ideas. ---------------------------------------------------------------------------------------------- Sub MoveCode() 'It produces event actions delete Save As and restore Save As code in "ThisWorkbook" module 'It copies from file module_code, into Module1 the code for the help file and delete Save As and restore Save As FName = FilePath & "module_code.txt" Set CurrentWorkbook = Workbooks(NewTimesheet) CurrentWorkbook.VBProject.VBComponents.Import FName Set VBCodeMod = Workbooks(NewTimesheet).VBProject.VBComponents("Th isWorkbook").CodeModule With VBCodeMod LineNum = .CountOfLines + 1 .InsertLines LineNum, "Private Sub Workbook_Activate()" & Chr(13) & " Delete_SaveAs" & Chr(13) & "End Sub" .InsertLines LineNum, "Private Sub Workbook_Deactivate()" & Chr(13) & " Restore_SaveAs" & Chr(13) & "End Sub" End With End Sub -------------------------------------------------------------------------------------------- |
All times are GMT +1. The time now is 12:18 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com