VBA Code durch VBA korrigieren
13.08.2020 18:13:29
Berny
ich habe großen Mist gebaut. Beim Aufbau eines Moduls in einem Formblatt habe ich eine fehlerhafte Eingabe gemacht.
Ich wollte abfragen, ob sich die Application im CutCopyMode befindet Ich frage aber nur nach dem copy modus.
Application.CutCopyMode = 1
anstatt
Application.CutCopyMode = xlCopy Or Application.CutCopyMode = xlCut
So und jetzt wurde das Formblatt 100 + x mal verwendet.
Ich hatte vor langer Zeit ein Modul aus einem Forum, welches einen Code ersetzt. Das habe ich jetzt versucht, aber es funktioniert leider nicht.
Sub ersetzen()
Datei = "Test.xlsm"
Modulname = "Tabelle1"
Workbooks(Datei).Activate
With Workbooks(Datei).VBProject.VBComponents(Modulname).CodeModule
PcStrLn = 1
PcLnCnt = .CountOfLines
Strng = .Lines(1, .CountOfLines)
CngdStrng = Replace(Strng, "'Application.CutCopyMode = 1'", "'Application.CutCopyMode = _
xlCopy Or Application.CutCopyMode = xlCut'", 1, , vbTextCompare)
.DeleteLines 1, .CountOfLines
.AddFromString CngdStrng
End With
End Sub
Warum wird hier nichts ersetzt? Gibt es eine andere, bessere Methode?
M.f.G.
Berny