Microsoft脚本控制 [英] Microsoft Script Control
问题描述
我正在使用Microsoft Scripting Controls将json文件导入Excel。
我正在尝试在工作簿中设置多个工作表,其中只有一个数据是床单之间的变体。但是我无法让脚本引擎从一个工作表重置为另一个工作表。每次重置脚本引擎需要做什么?谢谢
Public Sub InitScriptEngine()
Set ScriptEngine = New ScriptControl
使用ScriptEngine
.Language =" JScript"
.AddCode" function getProperty(jsonObj,propertyName){return jsonObj [propertyName]; }"
.AddCode" function getSubProperty(jsonObj,podId,propertyName){return jsonObj.gallery.podCache [podId] [propertyName]; }"
.AddCode" function getKeys(jsonObj){var keys = new Array(); for(var i in jsonObj.gallery.podCache){keys.push(i);返回键; }"
结束
结束子
这是一个管理脚本论坛,所以你可能在错误的地方。
那说"重置"是什么意思。除非变量是全局变量,否则控制将在sub的末尾重置。如果是这种情况那么你的意思是"重置"。
要重新初始化控件,你只需"新"即可。再次。
我建议使用CreateObject而不是New< object>。
设置sce = CreateObject(" MSScriptControl.ScriptControl" ;)
sce.Reset()
I am importing a json file to Excel using Microsoft Scripting Controls.
I am trying to set up several sheets within the workbook, where only one piece of data is the variant between sheets. However I can't get the Script Engine to reset from sheet to sheet. What do I need to do to have the script engine reset each time? Thanks
Public Sub InitScriptEngine() Set ScriptEngine = New ScriptControl With ScriptEngine .Language = "JScript" .AddCode "function getProperty(jsonObj, propertyName) { return jsonObj[propertyName]; } " .AddCode "function getSubProperty(jsonObj, podId, propertyName) { return jsonObj.gallery.podCache[podId][propertyName]; } " .AddCode "function getKeys(jsonObj) { var keys = new Array(); for (var i in jsonObj.gallery.podCache) { keys.push(i); } return keys; } " End With End Sub
This is an admin scripting forum so you are probably in the wrong place.
That said what do you mean by "reset". The control is reset at the end of the sub unless the variable is global. If that is the case then what do you mean by "reset".
To reinitialize the control you can just "New" it again.
I recommend using CreateObject and not New <object>.
Set sce = CreateObject("MSScriptControl.ScriptControl")
sce.Reset()
这篇关于Microsoft脚本控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!