//In the German version of Outlook the default command bar
//is named "Standard". In other language versions of Outlook
//this name could differ, then you need to modify the next line
Office.CommandBar cmdBar = cmdBars["Standard"];
What's standard in italian and english versions?
I have a document level application for Excel 2010 using VSTO and c#. The following code is used to call the Excel Growth function.
double known_Ys, new_Ys, known_Xs, new_Xs;
// Both of the known arrays have a length of 7
// The new arrays have a length of 5
// All arrays were loaded with valid double values
// except new_Ys which will contain the result
Excel.WorksheetFunction wsf = Application.WorksheetFunction;
object results = wsf.Growth(known_Ys, known_Xs, new_Xs, System.Type.Missing);
While debugging, "results" show a type of 'System.Object[*]' which is a System.Object with an undefined lower boundary.
Looking at the variable, there is an array of double values that appear to be correct. The lower boundary is 1, and the upper boundary is 5.
When attempting to cast the results to either object or double, I get an exception, "Unable to cast object of type 'System.Object[*]' to type 'System.Object' or 'double'.
I've also unsuccessfully tried to use the static methods of the Array class to copy the contents out.
Any thoughts on a resolution would be appreciated.
I don't want to use VBA code to resolve the problem if it can be avoided.
I've also considered a work-around, using a hidden worksheet to perform the calculations and copying the results into the c# application, but feel I should be able to handle it in the c# code.
I found the following work-around, unless someone has a better solution.
"results" inherits from System.Array.
System.Array resultsArray = results as System.Array;
if (resultsArray != null)
int idx = resultsArray.GetLowerBound(0);
for (int i = 0; i < new_Ys.Length; i++)
new_Ys[i] = (double)resultsArray.GetValue(idx);
// Handle exception.
The conflict is that c# vectors (one dimensional arrays) are always zero based, so explicit casts won't work.
The problem is that the button click event is happening almost immediately - so the second "click" is going to the correct place - the control at that position on the "new" panel. And that will generate a click event for the new button because that is exactly what should happen.
If you want to stop it, then
1) Create a class level variable:
private DateTime lastSwap = DateTime.Now;
2) In the Button1 click handler, set it:
lastSwap = DateTime.Now;
And then swap panels.
3) In the Button2 click handler, check it and ignore if too soon:
if (DateTime.Now < lastSwap.AddMilliseconds(500)) return;
You can change the 500 to any value you think reasonable - 500 provides half a second.
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.