It would be nice if one can run node.js code inside Excel user-defined functions. Something like using js code like VBA. I googled for solutions but cannot find any. Is it possible to do this?
Asked
Active
Viewed 1,107 times
4
-
You can (eg) use a `ScriptControl` object from VBA to run javascript, and more-recent version(s) of excel support some level of js scripting - https://dev.office.com/reference/add-ins/excel/application But that's not really the same thing as running node.js – Tim Williams Feb 25 '17 at 08:03
-
At the moment Office-JS addins do not support UDFs: but see Uservoice https://officespdev.uservoice.com/forums/224641-feature-requests-and-feedback/suggestions/6936956-add-user-defined-function-support-to-the-apps-for – Charles Williams Feb 25 '17 at 14:37
-
Do you want to use packages from npm? – Raymond Lu May 22 '20 at 07:35
-
@Raymond Lu, I think that's usually unavoidable when using node.js – user3848207 May 22 '20 at 08:52
-
I would like to suggest a hacky way: Make a node server on your localhost and call the API endpoint using VBA HTTP request. – VaibhavJoshi May 25 '20 at 21:27
1 Answers
2
Yes, if you want to use packages from NPM. You could use webpack to combine all the stuff to one js file, it should work.
webpack as a static module bundler for modern JavaScript applications. When webpack processes your application, it internally builds a dependency graph which maps every module your project needs and generates one or more bundles. you could refers to this document.
You could also refer to a sample, Yeoman, the Yeoman generator creates a Node.js Office Add-in project. it use webpack combine all files into one js file.

Raymond Lu
- 2,178
- 1
- 6
- 19
-
office JS code cannot be run in VBA, but you can call Excel Graph API in VBA – Raymond Lu May 28 '20 at 15:28