Gruppe
VBE
Problem
Der Code eines VBA-Moduls soll in Zelle A1 als Kommentar angezeigt werden.
StandardModule: Modul1
Sub GetCode()
Dim cmt As Comment
Dim sCode As String
With ThisWorkbook.VBProject.VBComponents("Modul1").CodeModule
sCode = .Lines(1, .CountOfLines) & vbLf & vbLf & "Aktualisierung: " & Now
End With
sCode = Replace(sCode, vbCr, "")
With Range("A1")
If Not .Comment Is Nothing Then
.Comment.Delete
End If
Set cmt = .AddComment(sCode)
cmt.Shape.TextFrame.AutoSize = True
End With
End Sub