K
Klaus
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("ThisWorkbook").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
--------------------------------------------------------------------------------------------
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("ThisWorkbook").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
--------------------------------------------------------------------------------------------