动态执行文本vba代码

动态执行文本vba代码

Public Sub StringExecute(s As String)

    Dim vbComp As Object

 

   

    Set vbComp = ThisWorkbook.VBProject.VBComponents.Add(1)

    vbComp.Name = "aaa"

    vbComp.CodeModule.AddFromString "Sub foo" & vbCrLf & s & vbCrLf & "End Sub"

   

 

   

    Application.Run vbComp.Name & ".foo"

    ThisWorkbook.VBProject.VBComponents.Remove vbComp

End Sub

 

Sub Testing()

    StringExecute "MsgBox" & """" & "Job Done!" & """"

End Sub

上一篇:需求管理(REQM,Requirements Management)工具(转)


下一篇:redis基本命令学习