Sub sample() Dim code code = "function greeting(x){return 'hello ,'+x}" Set js = CreateObject("ScriptControl") js.Language = "JScript" js.AddCode code Debug.Print js.Run("greeting", "Jack") End Sub