Hey Guys,
Done it...
First of all Thanks to Patrick and Austin who are always there to help ppl
like us...
You ppl are great guys...
I made use of the Attribute "startFromScratch"
[Thanks Patrick, I saw this word on your site and started my search on the
same.]
Any ways, the Problem and Solution goes like this,
I have an PowerPoint 2007 add-in which allows the user to enter some details,
and when he is finished he clicks on a button avaiable as a part of add-in.
This generates a Report
which gives user some details about the activity he has done.
I wanted to restrict the user from updating the Report, so I made the slide
disable by EnableWindow API.
And also changed the the Presentation package as MarkeAsFinal
This worked, as MarkAsFinal does not allow the user to use many of the Tab
Options.
But it was not to fullproof solution, the user can change the status of
MarkAsFinal and make use of any Tab on the Ribbon Control.
Even if I hide it from the OfficeMenu, he can go to the Office Options, add
MarkAsFinal command to Quick Access Toolbar and change the status
.... All the hard work, Gone with the wind ...
Then as I said I saw the word "startFromScratch" on Patrick's site, and
started searching for the same,
I read somewhere that when we make the "startFromScratch=true",
It only hides the Tabs on Ribbon Control, but it ristricts the user to
manipulate Quick Access Toolbar.
So I tride as bellow and it worked,
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// File connect.cs / Alternativly you can also use CustomUI.xml
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
[GuidAttribute("0B539378-8505-46A5-A391-2DCF5BAC469E"),
ProgId("PowerPoint_Add_In.Connect")]
public class Connect : Object, Extensibility.IDTExtensibility2,
Office.IRibbonExtensibility
{
static Office.IRibbonUI ribbon;
public void OnConnection(object application,
Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array
custom)
{
applicationObject = application;
addInInstance = addInInst;
}
string Microsoft.Office.Core.IRibbonExtensibility.GetCustomUI (string s)
{
return getResource();
}
private string getResource()
{
if (IsAddInLoaded)
{
string strContent = "";
strContent = "<customUI
xmlns='
http://schemas.microsoft.com/office/2006/01/customui'
onLoad='Ribbon_OnLoad'>"
+ "<commands>"
+ "<command idMso ='FileNew' onAction ='OnFileNew'/>"
+ "<command idMso ='FileNewDefault' onAction
='OnFileNew'/>"
+ "<command idMso ='FileOpen' onAction
='OnFileOpen'/>"
+ "<command idMso ='FileClose' onAction
='OnFileClose'/>"
+ "<command idMso ='FileCloseOrExit' onAction
='OnFileClose'/>"
+ "<command idMso ='FileSave' onAction
='OnFileSave'/>"
+ "</commands>"
// startFromScratch='true'
+ "<ribbon startFromScratch='true'>"
// This part is not required as "strartFromScratch=true" takes care of
all the menu items
// I have kept it here just for infromation, that if in case any one
wants to remove commands from Office Menu.
+ "<officeMenu>"
+ "<menu idMso='FilePrepareMenu' visible='false' />"
+ "<toggleButton idMso='FileMarkAsFinal' visible='false' />"
+ "</officeMenu>"
// Make default tabs visible.
+ "<tabs>"
+ "<tab idMso='TabHome' visible='true' label='Home' />"
+ "<tab idMso='TabInsert' visible='true' label='Insert' />"
+ "<tab idMso='TabDesign' visible='true' label='Design' />"
+ "<tab idMso='TabAnimations' visible='true' label='Animations' />"
+ "<tab idMso='TabSlideShow' visible='true' label='Slide Show' />"
+ "<tab idMso='TabReview' visible='true' label='Review' />"
+ "<tab idMso='TabView' visible='true' label='View' />"
// Add Custom Tab for Print
+ "<tab id='tabPrint' label='Print'>"
+ "<group id='grpPrint' label='Print'>"
+ "<button id='btnPrintPreview' size='large' label='Print Preview'
onAction ='OnPrintPreview' image='FilePrintPreview' />"
+ "<button id='btnPrint' size='large' label='Print' onAction ='OnPrint'
image='FilePrint' />"
+ "</group></tab>"
+ "</tabs>"
+ "</ribbon>"
+ "</customUI>";
return strContent;
}
else
return "";
}
public void Ribbon_OnLoad(Office.IRibbonUI r)
{
ribbon = r;
}
public void OnFileOpen(Office.IRibbonControl control, ref bool
CancelDefault)
{
if (IsAddInLoaded)
CancelDefault = true;
else
CancelDefault = false;
}
public void OnFileNew(Office.IRibbonControl control, ref bool
CancelDefault)
{
if (IsAddInLoaded)
CancelDefault = true;
else
CancelDefault = false;
}
public void OnFileSave(Office.IRibbonControl control, ref bool
CancelDefault)
{
if (IsAddInLoaded)
CancelDefault = true;
else
CancelDefault = false;
}
public void OnFileClose(Office.IRibbonControl control, ref bool
CancelDefault)
{
if (IsAddInLoaded)
CancelDefault = true;
else
CancelDefault = false;
}
private object applicationObject;
private object addInInstance;
public void OnPrint(Office.IRibbonControl control)
{
((Microsoft.Office.Interop.PowerPoint.Application)
applicationObject)
.CommandBars.ExecuteMso("FilePrint");
}
public void OnPrintPreview(Office.IRibbonControl control)
{
((Microsoft.Office.Interop.PowerPoint.Application)
applicationObject)
.CommandBars.ExecuteMso("FilePrintPreview");
}
//+++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++
// Other "IDTExtensibility2" implementation is required
//+++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++
}
--
D.C
....on the deadline, project should be buried where it belongs...
....can be done...