dynamically loading external macros, on the fly

  • Thread starter Thread starter sp00nix
  • Start date Start date
S

sp00nix

I'm am trying to create somewhat of a scripting scheme so that the en
user can format their reports, but not be limited to just what m
scripting scheme offers. Basically, i want people who are not familia
with the macro side of excel to still be able to do powerful things
such as customization.

In order to complete this project, i imagine i will need to load .ba
files, or text files containing macros on the fly.

If i have a directory called "\scripts", how can i run a text file i
that directory as a macro?

thanks,
sp00
 
From Chip Pearson's site - shows how to export to a text file, then import
into another workbook.

Sub CopyOneModule()

Dim FName As String
With Workbooks("Book2")
FName = .Path & "\code.txt"
.VBProject.VBComponents("Module1").Export FName
End With

' --- line your looking for ---
Workbooks("book1").VBProject.VBComponents.Import FName

End Sub

http://www.cpearson.com/excel/vbe.htm
 
Back
Top