### Install node-activex Package Source: https://github.com/durs/node-activex/blob/master/README.md Demonstrates how to install the node-activex package using npm, including specific versions for MSVS. ```bash npm install winax npm install winax --msvs_version=2015 npm install winax --msvs_version=2017 ``` -------------------------------- ### Clone and Install Project Source: https://github.com/durs/node-activex/blob/master/README.md Clones the node-activex repository from GitHub and installs its dependencies using npm. ```bash git clone git://github.com/durs/node-axtivex.git cd node-activex npm install ``` -------------------------------- ### Install Debug Version Source: https://github.com/durs/node-activex/blob/master/README.md Installs the debug version of the project dependencies using npm. ```bash npm install --debug ``` -------------------------------- ### Run Unit Tests Source: https://github.com/durs/node-activex/blob/master/README.md Installs the Mocha testing framework globally and then runs the project's unit tests. ```bash npm install -g mocha mocha --expose-gc test ``` -------------------------------- ### Install Windows Build Tools Source: https://github.com/durs/node-activex/blob/master/README.md Installs the necessary build tools for Windows development, including Visual C++ build tools and Python, using npm. ```bash npm install --global --production windows-build-tools ``` -------------------------------- ### Instantiate ActiveXObject with Options Source: https://github.com/durs/node-activex/blob/master/README.md Demonstrates how to create an ActiveXObject instance with specific configuration options. The options control whether to activate an existing instance, use a file name in the ROT, or utilize type information for resolution. ```javascript var con = new ActiveXObject("Object.Name", { activate: false, // Allow activate existance object instance (through CoGetObject), false by default getobject: false, // Allow using name of the file in the ROT (through GetAccessibleObject), false by default type: true // Allow using type information, true by default }); ``` -------------------------------- ### Build Project with node-gyp Source: https://github.com/durs/node-activex/blob/master/README.md Configures and builds the project using node-gyp, a tool for compiling native Node.js addons. ```bash node-gyp configure node-gyp build ``` -------------------------------- ### ADO Connection Operations with node-activex Source: https://github.com/durs/node-activex/blob/master/README.md Illustrates opening an ADO connection, creating a simple table, inserting data, and performing a select query to retrieve records. ```javascript con.Open('Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\tmp;Extended Properties="DBASE IV;"', '', ''); con.Execute("Create Table persons.dbf (Name char(50), City char(50), Phone char(20), Zip decimal(5))"); con.Execute("Insert into persons.dbf Values('John', 'London','123-45-67','14589')"); con.Execute("Insert into persons.dbf Values('Andrew', 'Paris','333-44-55','38215')"); con.Execute("Insert into persons.dbf Values('Romeo', 'Rom','222-33-44','54323')"); ``` ```javascript var rs = con.Execute("Select * from persons.dbf"); var reccnt = rs.RecordCount; ``` ```javascript var fields = rs.Fields; var fldcnt = fields.Count; ``` -------------------------------- ### Create ADO Connection with node-activex Source: https://github.com/durs/node-activex/blob/master/README.md Shows two methods for creating an ADODB.Connection object using the node-activex package: via a global function or the Object prototype. ```javascript require('winax'); var con = new ActiveXObject('ADODB.Connection'); ``` ```javascript var winax = require('winax'); var con = new winax.Object('ADODB.Connection'); ``` -------------------------------- ### Run nodewscript Command Source: https://github.com/durs/node-activex/blob/master/README.md Executes a JavaScript file using the 'nodewscript' command, which emulates the Windows Script Host (WSH) environment within Node.js. ```bash nodewscript [options] ``` -------------------------------- ### Include node-activex as a Library Dependency Source: https://github.com/durs/node-activex/blob/master/README.md Shows how to include node-activex as a dependency in a binding.gyp file for use in native Node.js addons, enabling access to COM VARIANT translation functions. ```python "dependencies": [ " Person: " + name + " from " + town + " phone: " + phone + " zip: " + zip); rs.MoveNext(); } ``` ```javascript rs.MoveFirst(); while (rs.EOF != false) { var name = fields[0].value; var town = fields[1].value; var phone = fields[2].value; var zip = fields[3].value; console.log("> Person: " + name + " from " + town + " phone: " + phone + " zip: " + zip); rs.MoveNext(); } ``` -------------------------------- ### TypeScript tsconfig.json Configuration for node-activex Source: https://github.com/durs/node-activex/blob/master/README.md Provides essential configurations for the tsconfig.json file when using node-activex with TypeScript, focusing on moduleResolution and excluding 'ScriptHost' from the lib option. ```json { "compilerOptions": { "target": "esnext", "module": "nodenext" } } ``` ```json { "compilerOptions": { "lib": [ "ESNext" ] } } ``` -------------------------------- ### Include node-activex Header in C++ Code Source: https://github.com/durs/node-activex/blob/master/README.md Demonstrates how to include the node-activex header file in C++ code to access functions for translating between COM VARIANT and Node.js types. ```cpp #include ``` -------------------------------- ### Working with Excel Ranges using node-activex Source: https://github.com/durs/node-activex/blob/master/README.md Illustrates how to interact with Excel ranges using two-dimensional arrays, including setting values, handling missing data, and retrieving cell values. ```javascript var excel = new winax.Object("Excel.Application", { activate: true }); var wbk = excel.Workbooks.Add(template_filename); var wsh = wbk.Worksheets.Item(1); wsh.Range("C3:E4").Value = [ ["C3", "D3", "E3" ], ["C4", "D4", "E4" ] ]; wsh.Range("C3:E4").Value = [ ["C3", "D3", "E3" ], "C4" ]; // will let D4 and E4 empty wsh.Range("C3:E4").Value = [ [null, "D3", "E3" ], "C4" ]; // will let C3, D4 and E4 empty wsh.Range("C3:F4").Value = [ [100], [200] ]; // will duplicate the two rows in colums C, D, E, and F wsh.Range("C3:F4").Value = [ [100, 200, 300, 400] ]; // will duplicate the for cols in rows 3 and 4 wsh.Range("C3:F4").Value = [ [100, 200] ]; // Will correctly duplicate the first two cols, but col E and F with contains "#N/A" const data = wsh.Range("C3:E4").Value.valueOf(); console.log("Cell E4 value is", data[1][2]); ``` -------------------------------- ### Working with COM Variant Types Source: https://github.com/durs/node-activex/blob/master/README.md Illustrates the usage of the `Variant` class for handling various COM data types in Node.js. It covers creating variant instances, by-reference variants, variant arrays, and modifying variant content through assignment, casting, and clearing. ```javascript var winax = require('winax'); var Variant = winax.Variant; // create variant instance var v_short = new Variant(17, 'short'); var v_short_byref = new Variant(17, 'pshort'); var v_int_byref = new Variant(17, 'byref'); var v_byref = new Variant(v_short, 'byref'); // create variant arrays var v_array_of_variant = new Variant([1,'2',3]); var v_array_of_short = new Variant([1,'2',3], 'short'); var v_array_of_string = new Variant([1,'2',3], 'string'); // change variant content var v_test = new Variant(); v_test.assign(17); v_test.cast('string'); v_test.clear(); // also may be used cast function var v_short_from_cast = winax.cast(17, 'short'); ``` -------------------------------- ### Create COM Object from JavaScript Object Source: https://github.com/durs/node-activex/blob/master/README.md Shows how to create a COM object directly from a JavaScript object. This allows passing complex data structures, including nested objects, arrays, and functions, as arguments to COM procedures. ```javascript var com_obj = new ActiveXObject({ text: test_value, obj: { params: test_value }, arr: [ test_value, test_value, test_value ], func: function(v) { return v*2; } }); ``` -------------------------------- ### WScript Function Setter Limitation Source: https://github.com/durs/node-activex/blob/master/README.md Illustrates a syntax error that occurs in V8 when attempting to set environment variables using the JScript syntax, which is valid in MS WScript. ```javascript var WshShell = new ActiveXObject("WScript.Shell"); var processEnv = WshShell.Environment("PROCESS"); processEnv("ENV_VAR") = "CUSTOM_VALUE"; // This syntax is valid for JScript, but will throw syntax error on v8 ``` -------------------------------- ### WScript Implicit Property Limitation Source: https://github.com/durs/node-activex/blob/master/README.md Demonstrates a limitation in the V8 engine compared to MS WScript regarding implicit properties. If a property is dynamic or not explicitly defined, execution might not reach certain code blocks even if the property is null or false. ```javascript var a = WScript.CreateObject(...) if( a.Prop ) { // If 'Prop' is a dynamic property (i.e. it is not defined in TypeInfo and // not marked explicitly as a property, then execution never gets here. Even if a.Prop is null or false. } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.