node-activex
node-activex copied to clipboard
How to pass a string with value `"default"` as a parameter?
Whenever I try to pass a value of "default" into a function, it seems to get ignored.
const winax = require('winax')
const excel = new winax.Object('Excel.Application', { activate: true })
excel.Workbooks.Add()
excel.Workbooks.Item(1).SaveAs('default')
// Instead of saving as "default.xlsx", it saves as the default name of "Book1.xlsx"
// as if `.SaveAs()` was called without parameters.
excel.Workbooks.Add()
excel.Workbooks.Item(2).SaveAs('asdf')
// This saves as "asdf.xlsx" as expected
I've tried the following:
workbook.SaveAs('default')
workbook.SaveAs(new winax.Variant('default', 'string'))
workbook.SaveAs(winax.cast('default', 'string'))
Seems like this method is responsible for checking if the value is equal to "default".
https://github.com/durs/node-activex/blob/8f226abaa88f6e61be4e3af1978b058d5517dcb3/src/utils.h#L403
If this behavior is necessary, is it possible to change the string to something that wouldn't ever conflict? I really need to pass a string of "default".
// Some very unique string
winax.Default = '{{WINAX_DEFAULT_PARAM}}'
const winax = require('winax')
// This passes a string with value "default"
workbook.SaveAs('default')
// This uses the default value of the parameter
workbook.SaveAs(winax.Default)