7 ms·
Great question! Programmatically copy your snippet to a module, then call it: Public Sub AppendCode() Dim cm As Object Set cm = Application.VBE.VBProje
by blargthorwars 9mo ago
Great question! Programmatically copy your snippet to a module, then call it:
Public Sub AppendCode()
Dim cm As Object
Set cm = Application.VBE.VBProjects(1).VBComponents("GeneratedLogic").CodeModule
cm.InsertLines cm.CountOfLines + 1, _
"Public Sub NewProc()" & vbCrLf & _
" MsgBox ""Dynamically added""" & vbCrLf & _
"End Sub"
End Sub
- mschuster91 9mo agoI've written my fair share of evil shit in VBA. But... what is effectively eval() just in VB? Yikes.
- moron4hire 9mo agoFor the people who would be using this, they would almost never even have other people's code, say nothing of whether it's untrusted.
- n013 9mo agoHonestly, ASF is literally sandboxed. Objects cannot be injected in the runtime. Also, VBA Expressions is intentionally limited to receive and return VBA strings. So, the system is safe for execute code from (almost) anyone.