Horace
Horace

Reputation: 342

VBScript ScriptControl Eval with variables

Having problems with this and couldn't find a solution online that was more specific to what I am having trouble with.

I have an expression like this

pictureFolderFullPath = "C:\Work"

'Create Script Control Obj
Dim sc As ScriptControl
Set sc = CreateObject("ScriptControl")
sc.Language = "VBScript"

Dim content As String
content = sc.Eval("pictureFolderFullPath & "\3.jpg"")

Then, the content becomes only "\3.jpg", instead of having the full path of the picture

Upvotes: 0

Views: 4287

Answers (1)

phd443322
phd443322

Reputation: 503

Makes run-time functionality available to a scripting engine.

Syntax

ScriptControl.AddObject(name, object[, addMembers])

The AddObject method has these parts:

Part Description

name    Required. Name by which the added object is to be known in ScriptControl code.
object  Required. Name of the object exposed at run time.
addMembers  Optional. Boolean value. True if members of object are globally accessible; False if they are not.

Remarks

Use the AddObject method to make run-time functionality available to a scripting engine. The AddObject method enables a ScriptControl user to provide a set of name/object pairs to the scripting code. The scripting engines may expose the name in any way. In both VBScript and JScript, each name appears as a globally accessible name.

Upvotes: 1

Related Questions