Ein hochinteressantes Thema: 'Makro �ndert Makro'
Dieses Beispiel �ndert eine Zeile im Code:
Const SuchZeile = " MsgBox ""VBA macht Spa� !"""
Const NeueZeile = " MsgBox ""VBA macht gro�en Spa� !"""
Sub VBAZeile�ndern()
Set VBE = Application.VBE.ActiveCodePane.CodeModule
With VBE
For x = 1 To .CountOfLines
If .Lines(x, 1) = NeueZeile Then
.ReplaceLine x, SuchZeile
Exit Sub
End If
If .Lines(x, 1) = SuchZeile Then
.ReplaceLine x, NeueZeile
Exit Sub
End If
Next x
End With
End Sub
Sub Testen()
MsgBox "VBA macht Spa� !"
End Sub
|