Cube Analysis Addin and c#

C

Cricket

Hi!

I have a problem with the Cube analysis add-in.
I have to open an Excel file contains a report from C# code and change a
cell value. The cell witch I want to change is a filter value in the report
and the report is converted to free form.

I have tried to make this in a lot of way and realized finally that the Cube
analysis add-in isn't working. If I open the excel file manually there's
everything good.

Finally I wrote a little code just to open the excel file and see what will
happen if I change the specific value manually in the window that appears. In
this case the report isn't refreshed too.

So my main problem is that If I open the excel file manually there's
everything OK, but if I open the same file from code than the report isn't
refreshing.

Thanks
 
C

Cricket

Furthermore, If I launch the excel from C# code and change the value of the
cell, than all of the calculated cells got the #NAME? sign because it do not
recognize the function names like CUBECELLMEMBER...
 
J

Jim Thomlinson

Try adding this to install the addin to your instance of XL...

AddIns("Functions Class").Installed = True

Note that Cube Analysis has a nasty side effect of disabling events in XL so
after you finish whatever you are doing be sure to reset events.
Application.EnableEvents = True
 
C

Cricket

Thank you for the tips.
If I clearly understand what are you suggesting than I can say it isnt solve
my problem. If it is help I copy here a little code to show what I am doing
now. (just open the excel) I have writen a little code to set every add-in to
installed, but it didn't help. (If I open the excel from code it cant realize
the formula names...)

exWorkbook = ExcelObj.Workbooks.Open(stFilePath, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
// exWorkbook = ExcelObj.Workbooks.Open(stFilePath, 0, false, 5, "",
"", true, XlPlatform.xlWindows, "\t", false, false, 0, true, Missing.Value,
Missing.Value);

ExcelObj.EnableEvents = true;

for (int i=1; i<=ExcelObj.AddIns.Count; i++)
{
AddIn ad = ExcelObj.AddIns;
ad.Installed = true;
}
 
T

Tom Ogilvy

When you open Excel utilizing Automation such as you are doing, addins are
not loaded. This is the cause of your problem. Jim showed you some VBA code
to show how to load an addin using code. You would have to have your code
open excel, then issue commands to load the addin. When you open it
manually, the addin is loaded automatically - again, not the case when you
open Excel as you are doing.

--
Regards,
Tom Ogilvy


Cricket said:
Thank you for the tips.
If I clearly understand what are you suggesting than I can say it isnt solve
my problem. If it is help I copy here a little code to show what I am doing
now. (just open the excel) I have writen a little code to set every add-in to
installed, but it didn't help. (If I open the excel from code it cant realize
the formula names...)

exWorkbook = ExcelObj.Workbooks.Open(stFilePath, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
// exWorkbook = ExcelObj.Workbooks.Open(stFilePath, 0, false, 5, "",
"", true, XlPlatform.xlWindows, "\t", false, false, 0, true, Missing.Value,
Missing.Value);

ExcelObj.EnableEvents = true;

for (int i=1; i<=ExcelObj.AddIns.Count; i++)
{
AddIn ad = ExcelObj.AddIns;
ad.Installed = true;
}



Jim Thomlinson said:
Try adding this to install the addin to your instance of XL...

AddIns("Functions Class").Installed = True

Note that Cube Analysis has a nasty side effect of disabling events in XL so
after you finish whatever you are doing be sure to reset events.
Application.EnableEvents = True
 
P

Peter Nagy

Hi Cricket!

You must probaly this code:
ExcelObj.AddIns.Installed = false;

ExcelObj.AddIns.Installed = true;

This solution will resolve your problem, because the Excell in this case
will reload the addins.

Cricket said:
Thank you for the tips.
If I clearly understand what are you suggesting than I can say it isnt solve
my problem. If it is help I copy here a little code to show what I am doing
now. (just open the excel) I have writen a little code to set every add-in to
installed, but it didn't help. (If I open the excel from code it cant realize
the formula names...)

exWorkbook = ExcelObj.Workbooks.Open(stFilePath, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
// exWorkbook = ExcelObj.Workbooks.Open(stFilePath, 0, false, 5, "",
"", true, XlPlatform.xlWindows, "\t", false, false, 0, true, Missing.Value,
Missing.Value);

ExcelObj.EnableEvents = true;

for (int i=1; i<=ExcelObj.AddIns.Count; i++)
{
AddIn ad = ExcelObj.AddIns;
ad.Installed = true;
}



Jim Thomlinson said:
Try adding this to install the addin to your instance of XL...

AddIns("Functions Class").Installed = True

Note that Cube Analysis has a nasty side effect of disabling events in XL so
after you finish whatever you are doing be sure to reset events.
Application.EnableEvents = True
 
C

Cricket

Thank you falks!
I have solved the problem with Peters fantastic code.

For Tom Ogilvy:
I have allready understand what Jim said, and I wrote it how I am doing the
same thing in C# in my next post.

For Peter Nagy:
It was a nice solution, thank you :)


Peter Nagy said:
Hi Cricket!

You must probaly this code:
ExcelObj.AddIns.Installed = false;

ExcelObj.AddIns.Installed = true;

This solution will resolve your problem, because the Excell in this case
will reload the addins.

Cricket said:
Thank you for the tips.
If I clearly understand what are you suggesting than I can say it isnt solve
my problem. If it is help I copy here a little code to show what I am doing
now. (just open the excel) I have writen a little code to set every add-in to
installed, but it didn't help. (If I open the excel from code it cant realize
the formula names...)

exWorkbook = ExcelObj.Workbooks.Open(stFilePath, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value);
// exWorkbook = ExcelObj.Workbooks.Open(stFilePath, 0, false, 5, "",
"", true, XlPlatform.xlWindows, "\t", false, false, 0, true, Missing.Value,
Missing.Value);

ExcelObj.EnableEvents = true;

for (int i=1; i<=ExcelObj.AddIns.Count; i++)
{
AddIn ad = ExcelObj.AddIns;
ad.Installed = true;
}



Jim Thomlinson said:
Try adding this to install the addin to your instance of XL...

AddIns("Functions Class").Installed = True

Note that Cube Analysis has a nasty side effect of disabling events in XL so
after you finish whatever you are doing be sure to reset events.
Application.EnableEvents = True
--
HTH...

Jim Thomlinson


:

Furthermore, If I launch the excel from C# code and change the value of the
cell, than all of the calculated cells got the #NAME? sign because it do not
recognize the function names like CUBECELLMEMBER...

:

Hi!

I have a problem with the Cube analysis add-in.
I have to open an Excel file contains a report from C# code and change a
cell value. The cell witch I want to change is a filter value in the report
and the report is converted to free form.

I have tried to make this in a lot of way and realized finally that the Cube
analysis add-in isn't working. If I open the excel file manually there's
everything good.

Finally I wrote a little code just to open the excel file and see what will
happen if I change the specific value manually in the window that appears. In
this case the report isn't refreshed too.

So my main problem is that If I open the excel file manually there's
everything OK, but if I open the same file from code than the report isn't
refreshing.

Thanks
 

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