C# Form exposed to Excel does not like CalculateAll (F9)

P

pinkfloydfan

Hi all

I have a very strange problem / bug here that I was wondering if
anybody had come across before.

(Using Visual C# Express 2008, .Net 3.5, Excel 2003
All public static functions are exposed (and working) in Excel via
ExcelDna)

In addition to the functionality I have got working, I have a Form
written in C# that is accessed via the CommandBar. This form takes an
input of a target cell, the value of which will depend upon the output
of one of my UDFs.

When the OK button is pressed the following occurs:
1) the various settings in the classes behind this functions are
changed one at a time by a set amount
2) the worksheet is recalculated
3) the new value in that target cell is recorded
4) reset the changed value, repeat 1) to 3) for all the settings and
output all the results elsewhere

Now comes the strange part: it all works fine as long as I have never
previously pressed F9 or Ctrl-Alt-F9. Pressing Shift-F9 has no impact:
the results are displayed as expected but if I have pressed F9 any
time prior during this session of Excel, then while it appears to work
the results show no changes to the target cell's values.

Is there any reason why pressing F9 prior to running this Form (and
thereby the functionality it uses in C#) should mean that I don't see
any change in results?

I am totally stuck on this one and would really appreciate any
guidance you can give.

Thanks a lot
Lloyd
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top