Load VBA code from a text file

If you want to import source code from a text file, you can use the following code.

Sub fromTextFile()

Dim CodeModul As CodeModule

Dim i As Integer

Const Importfile = "c:\Macro.txt"

 

Set CodeModul = ThisWorkbook.VBProject.VBComponents("NewModule").CodeModule

 

With CodeModul

.AddFromFile Importfile

End With

End Sub

Write a comment

Comments: 0