wrote :: 2007.05.03

Sub Sample15()
With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
.AddFromFile "C:\Work\Macro.txt"
End With
End Sub


Sub Sample16()
With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
.AddFromString "Public buf As String"
End With
End Sub


CodeModule.InsertLines(line, code)
Sub Sample17()
With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
.InsertLines 7, vbTab & "Debug.Print Now()"
End With
End Sub


CodeModule.DeleteLines (startline [, count])
Sub Sample17()
With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
.DeleteLines 7
End With
Debug.Print Now()
End Sub
CodeModule.ReplaceLine(line, code)
Sub Sample17()
With ThisWorkbook.VBProject.VBComponents("Module1").CodeModule
.ReplaceLine 7, vbTab & "'この行はコメントです"
End With
Debug.Print Now()
End Sub

