Closed kenklin closed 1 year ago
That's right, when using the activate option, the code is called:
CComPtr<IUnknown> unk;
hrcode = GetActiveObject(clsid, NULL, &unk);
if SUCCEEDED(hrcode) hrcode = unk->QueryInterface(&disp);
To access an already running instance of Excel you must use the "getobject" option, not the "activate" one. Code sample:
var oApp = new winax.Object("Name of the File in the ROT", {getobject: true});
@somanuell Thanks for the JS-side example! Closing.
Aside - my Javascript code has been migrated to resides in an Excel Add-in.
I'm not familiar with Excel programming but have read https://learn.microsoft.com/en-us/office/vba/api/overview/excel and managed to use
winax
to launch a new instance of Excel with a supplied filenamef
and manipulate its worksheet's cells with code like this:My question is how to access an already running instance of Excel using
winax
? After some Googling, it seems I may need to somehow access Marshal.GetActiveObject ? If so, if you could point me to sample code usingwinax
, I'd be grateful - thanks in advance.