Skip to content Skip to sidebar Skip to footer

How To Evaluate Vbscript Expression From Javascript Via Vba

The latest MS Office update has disabled vbscript which I am using in Excel VBA to evaluate expressions. I have found this to be substantially faster than the VBA 'Evaluate' func

Solution 1:

Try this solution:

Sub Test()

    MsgBox Eval("1+2+3^4")

End Sub

Function Eval(s As String)

    Static oDoc As Object

    If oDoc Is Nothing Then
        Set oDoc = CreateObject("htmlfile")
        oDoc.parentWindow.execScript "Function EvalExpr(s): EvalExpr = Eval(s): End Function", "vbscript"
    End If
    Eval = oDoc.parentWindow.EvalExpr(s)

End Function

Post a Comment for "How To Evaluate Vbscript Expression From Javascript Via Vba"