ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Cube Analysis Addin and c# (https://www.excelbanter.com/excel-programming/391092-cube-analysis-addin-c.html)

Cricket

Cube Analysis Addin and c#
 
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

Cricket

Cube Analysis Addin and c#
 
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...

"Cricket" wrote:

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


Jim Thomlinson

Cube Analysis Addin and c#
 
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


"Cricket" wrote:

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...

"Cricket" wrote:

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


Cricket

Cube Analysis Addin and c#
 
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[i];
ad.Installed = true;
}



"Jim Thomlinson" wrote:

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


"Cricket" wrote:

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...

"Cricket" wrote:

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


Tom Ogilvy

Cube Analysis Addin and c#
 
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" wrote:
[i]
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" wrote:

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


"Cricket" wrote:

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...

"Cricket" wrote:

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


Peter Nagy

Cube Analysis Addin and c#
 
Hi Cricket!

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

ExcelObj.AddIns[i].Installed = true;

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

"Cricket" wrote:
[i]
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" wrote:

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


"Cricket" wrote:

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...

"Cricket" wrote:

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


Cricket

Cube Analysis Addin and c#
 
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" wrote:
[i]
Hi Cricket!

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

ExcelObj.AddIns[i].Installed = true;

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

"Cricket" wrote:

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" wrote:

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


"Cricket" wrote:

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...

"Cricket" wrote:

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



All times are GMT +1. The time now is 07:21 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com