durs / node-activex

Node.JS Implementaion of ActiveXObject
MIT License
329 stars 62 forks source link

How to pass a string with value `"default"` as a parameter? #142

Open pillowfication opened 1 month ago

pillowfication commented 1 month ago

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'))
pillowfication commented 1 month ago

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)