Unique identifier for each excel window

Add-in Express™ Support Service
That's what is more important than anything else

Unique identifier for each excel window
 
Kiru Marimuthu




Posts: 26
Joined: 2017-07-20
Hi

We are using RTD server in Excel 2016 which polls data from RestAPI. When there is HTTP error from RestAPI we are showing the modal error dialog message in the custom task pane.

When there is two excel workbook open, the messages are shown in both the windows.

How do I uniquely identify each excel window and show the message?

Thanks
Posted 05 Feb, 2018 12:10:05 Top
Andrei Smolin


Add-in Express team


Posts: 14966
Joined: 2006-05-11
Hello Kiru,

You can wrap your RTD server call in an XLL call: see section Inserting the RTD function in a user-friendly way at https://www.add-in-express.com/docs/net-excel-udf-tips.php#advanced-rtd. In this case, you can determine the caller cell: see section Determining the cell, worksheet or workbook your UDF is called from on that page. When the caller cell is known, you show the pane in the Excel window containing that cell. Note however that the user may open the same workbook in two or more windows; in this scenario you can show the pane in the active window or in all of them.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Feb, 2018 05:55:36 Top
Kiru Marimuthu




Posts: 26
Joined: 2017-07-20
Hi Andrei

Thank for earlier response. Unfortunately, the CallWorksheetFunction doesn't return ADXExcelRef.

Here is the code we got


var result = Module.CallWorksheetFunction(ADXExcelWorksheetFunction.Rtd,
                        "ExcelAddinExpress.RTDMetrics", "", "SecurityData",
                        securityId, securityType, metrics, direction,
                        aggregation, bucket, Math.Abs(dateFrom.ToOADate()) > 0 ? dateFrom.ToString("yyyy-MM-dd") : "",
                        filter);
                    //initial value, errors
                    if (result.Equals("#FetchingData") ||
                        result.Equals(ADXExcelError.xlErrorNull) ||
                        result.Equals(ADXExcelError.xlErrorNA) ||
                        result.Equals(ADXExcelError.xlErrorValue))
                    {
                        //logger.Info($"************************ Result {result}");
                        return result;
                    }

                    //dlm value
                    double answer;
                    if (double.TryParse(result.ToString(), out answer))
                    {
                        return answer;
                    }


The possible return values are "FetchingData", "ADXExcelError" or any valid decimal values.

Thanks
Posted 06 Feb, 2018 09:49:55 Top
Andrei Smolin


Add-in Express team


Posts: 14966
Joined: 2006-05-11
You should issue a separate ADXXLLModule.CallWorksheetFunction call to get the caller cell:
ADXExcelRef caller = Module.CallWorksheetFunction(ADXExcelWorksheetFunction.Caller) as ADXExcelRef;

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 06 Feb, 2018 09:55:48 Top