RTD UDF not executed on workbook open

220 views
Skip to first unread message

James

unread,
Feb 18, 2016, 12:10:54 AM2/18/16
to Excel-DNA
Hi there,

I'm sure this use to work before. I have a bunch of UDFs which have RTD observables. Everything works well (UDF's updating values when expected), until I save a workbook and open it again.

The UDF's are not re-executed on workbook open.

I have tried isvoliatile=true on the UDFs. However it doesn't trigger the UDF on workbook open?

I'm assuming its something simple, perhaps nothing to do with ExcelDNA..

I'm running ExcelDNA 0.33

CTRL-ALT-F9 after workbook open seems to kick the UDFs into gear, and they keep updating in real-time. 

My Excel 2013 is set to auto formula calculation.

Any help would be much appreciated.

James

Govert van Drimmelen

unread,
Feb 18, 2016, 2:00:39 AM2/18/16
to exce...@googlegroups.com
Hi James,

The first thing to try is make a brand new workbook with only one formula in, and check the behaviour.

I remember some issue when the workbook has errors and RTD not running, but I can't recall the details.

If a fresh workbook still has the same behaviour, write back and we can check with a sample project.

-Govert


From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of James [jim...@gmail.com]
Sent: 18 February 2016 07:10 AM
To: Excel-DNA
Subject: [ExcelDna] RTD UDF not executed on workbook open

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

James

unread,
Feb 18, 2016, 8:01:18 PM2/18/16
to Excel-DNA
Hi Govert,

Yes it fails with new workbooks and with only one formula in it..

 The UDF looks like:


 
       [ExcelFunction(Description = "Get the latest coordinate value for a point in the Chief Database",
           
Name = "ChiefLatestCoord", Category = "Chief", IsVolatile =true)]
       
public static object ChiefLatestCoord(
           
[ExcelArgument(Name = "Name", Description = "is the Chief Point Pathname or Alias (for example '/This/Point/Here' or 'ALIAS-1')")]
           
string name)
       
{
           
lock (Lock.syncRoot)
           
{
               
Cell me = new Cell((ExcelReference)XlCall.Excel(XlCall.xlfCaller));


               
string logit = "ChiefLatestCoord(" + name + ") " + me.ToString() + " ";


#if DEBUG
               
Log.Debug(logit + "started");
#endif


               
try
               
{
                   
if (name == null || name.Length <= 0)
                       
throw new Exception("Missing Alias or Pathname");


                   
PointObservable po;
                   
if(CH.FindAdd(logit, me, new[] { (Object)name }, out po) ) {
                   
                   
// new required


                       
Point point = Point(name);


#if DEBUG
                       
Log.Debug(logit + "watching for latest coord");
#endif
                       
                        point
.Watch(po.Observable);
                   
}


                   
Debug.Assert(po.Observable != null);


#if DEBUG
                   
Log.Debug(logit + "finished " + po.Observable.ToString() + " ");
#endif
                   
StaticThread.Instance.Wake();


                   
return ExcelAsyncUtil.Observe("ChiefLatestCoord", XlCall.Excel(XlCall.xlfCaller),
                       
new ExcelObservableSource(() => po.Observable));
               
}
               
catch (Exception ex)
               
{
                   
Log.Error(logit + ex.ToString());
                   
throw ex;
               
}
           
}
       
}





James

Govert van Drimmelen

unread,
Feb 19, 2016, 5:01:30 AM2/19/16
to exce...@googlegroups.com
Hi James,

I've tried now and get the same problem, where the observable does not start again when re-opening a book.
I also expected this to work.

It's a bit tricky due to how Excel-DNA sets up the RTD server for the observable, so maybe there is now a bug.
I notice for a regular ExcelRtdServer-based function it does restart properly. So it might have to do with how the special server implemented for the async and observables get hooked up.

I've added an issue on GitHub to follow up: https://github.com/Excel-DNA/ExcelDna/issues/60

-Govert


Sent: 19 February 2016 03:01 AM
To: Excel-DNA
Subject: Re: [ExcelDna] RTD UDF not executed on workbook open

--

James

unread,
Mar 3, 2016, 8:00:33 PM3/3/16
to Excel-DNA
Hi Govert,

It does seem to work when the Cell is saved with a #NA or is it #VALUE cell value..

Presumably Excel re-triggers those cell formulas separately to a good value cell..

James
To post to this group, send email to exc...@googlegroups.com.

Govert van Drimmelen

unread,
Mar 25, 2016, 6:33:43 AM3/25/16
to Excel-DNA
Hi James,

I've found the bug - it was introduced in version 0.33 by a fix to another RTD-related update problem.
Internally, the RTD topic used for the Observe(...) was kept at #N/A, though the value returned to the UDF was correct. When Excel re-opens the book, RTD topics with stored error values do not seem to trigger an update.

The fix has been checked into GitHub.

I'm not sure this entirely agrees with your observation about the #NA or #VALUE, so it would be worth for you to check that everything now works right.

Thank you for reporting the issue.

Regards,
Govert

James

unread,
Mar 29, 2016, 9:33:20 PM3/29/16
to Excel-DNA
Hi Govert,

I've just tested it & it looks good.

Thanks!

James
Reply all
Reply to author
Forward
0 new messages