S
Sanjeev Burge
Hi all,
I have an application which launches Powerpoint and adds a commandbar with a pop-up button in it runtime. On click of pop-up button my app perform certain action.
The problem is that first time it adds the command bar without any problem. Everything goes fine, but when second time my app launches Powerpoint it throws an exception saying "invalid parameter" at line where i add the command bar.
oCommandBar = pptApp.CommandBars.Add( ("MyBar",Office.MsoBarPosition.msoBarTop,oMissing,oMissing);
The reason being simple that a command bar with same name already exists. But i have written a code which first tries find if any commandbar with name "MyBar" exists. If it exists it deletes that bar and then add the commandbar.
Here's the code to find if command bar exists
oCommandBars = pptApp.CommandBars;
for(int i=1; i < oCommandBars.Count; i++)
{
oCommandBar = oCommandBars;
string name = oCommandBar.Name;
if(name.ToLower() == "MyBar")
{
oCommandBars.Delete();
break;
}
}
But for some reason it dosen't find any command bar with name "MyBar", whereas the commandbar exists. The same code works for Excel.
Could any body put some more light on this issue. I appreciate anybodys help. I badly need any help on this.
Regards,
Sanjeev burge
I have an application which launches Powerpoint and adds a commandbar with a pop-up button in it runtime. On click of pop-up button my app perform certain action.
The problem is that first time it adds the command bar without any problem. Everything goes fine, but when second time my app launches Powerpoint it throws an exception saying "invalid parameter" at line where i add the command bar.
oCommandBar = pptApp.CommandBars.Add( ("MyBar",Office.MsoBarPosition.msoBarTop,oMissing,oMissing);
The reason being simple that a command bar with same name already exists. But i have written a code which first tries find if any commandbar with name "MyBar" exists. If it exists it deletes that bar and then add the commandbar.
Here's the code to find if command bar exists
oCommandBars = pptApp.CommandBars;
for(int i=1; i < oCommandBars.Count; i++)
{
oCommandBar = oCommandBars;
string name = oCommandBar.Name;
if(name.ToLower() == "MyBar")
{
oCommandBars.Delete();
break;
}
}
But for some reason it dosen't find any command bar with name "MyBar", whereas the commandbar exists. The same code works for Excel.
Could any body put some more light on this issue. I appreciate anybodys help. I badly need any help on this.
Regards,
Sanjeev burge