Using C#, I'm writing a program that has to use Excel only in order to edit some tabular data provided by my program. My program just creates an Excel application (the Microsoft.Office.Interop.Excel.Application object), creates within it a workbook, creates a worksheet, puts the data in Excel, and, after this, allows to a user to edit these data. The edited data can be easily read by my program. That's, in principal, all what I need from Excel.
This, therefore, means that a user of my program should not be able to format data in Excel, save an Excel file to the hard drive, open Excel files, and so on and so on. A user even does not need the Excel ribbon. Working with formulas is also does not required. Hotkeys (like "Ctrl + B" making the font bold, "Ctrl + S" saving the file, and so on) should be also not workable.
My question is: Is there a way to simply set such a minimalist interface for Excel? Or I should disable any aspect mentioned above by hand, step by step (disable the ribbon, switch off the hotkeys ans so on)?
When working within a VSTO project, you can disable most/all of the UI by using a custom ribbon XML file (there is a visual designer too but I doubt it would be sufficient for this).
To remove things, add a section for what you're removing, and set visible="false" or enabled="false" (users could still potentially add it back to the ribbon, but disabling it makes it grayed out).
e.g.:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<commands>
<command idMso="Cut" enabled="false" />
</commands>
<ribbon>
<tabs>
<tab idMso="TabHome" visible="false" />
</tabs>
</ribbon>
<contextualTabs>
<tabSet idMso="TabSetDrawingTools" visible="false" />
</contextualTabs>
<backstage>
<tab idMso="TabInfo" visible="false">
</backstage>
<contextMenus>
<contextMenu idMso="ContextMenuText">
<!-- you can't hide a context menu entirely, you have to hide each item -->
<button idMso="FontDialog" visible="false" />
</contextMenu>
</contextMenus>
</customUI>
This may also be possible if you're working with Office in the way that you seem to be, I don't really know.
Related
I have made an addin (New Flux Ad Mail) for Outlook and would like to move it's position next to the "New" group - see picture.
Currently, I have this in my xml:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon startFromScratch="false">
<tabs>
<tab idMso="TabMail">
<group id="fluxAdMail" label="Flux Ad Mail">
<button id="btnNewFluxMail" label="New Flux Ad Mail" onAction="click" size="large" imageMso="NewMail"/>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I noticed that there's something in the <group> section called insertAfterMso and I'm wondering if that's what I need to use set the position of my group. However, I have a hard time finding any information regarding this or what the different name/id is for the controls
Any help would be appreciated
You are on the right avenue - the insertAfterMso attribute specifies the identifier for the built-in control after which to position this control. You can can find the list of built-in control IDs at https://github.com/OfficeDev/office-fluent-ui-command-identifiers . Use the GroupMailNew idMso value for the insertAfterMso attribute in case of Explorer windows.
If you only need to find control names, you can discover them within Office applications by hovering over commands in the Customize Ribbon tab of the Options dialog and looking at the tooltip:
I am developing a Microsoft Excel Addin.
I need to add a button on context menu (right click) on cell selected text. I have found the ContextMenuCell idMso but this works only on whole cell right click.
Here is my ribbon's xml:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
</ribbon>
<contextMenus>
<contextMenu idMso="ContextMenuCell">
<button id="TranslateTextButton" label="Test Label" onAction="OnRibbonClick" getImage="GetIcon"/>
</contextMenu>
</contextMenus>
</customUI>
I wonder if exists something like ContextMenuCell for cell's text and not whole cell. Thank you in advance!
After many searches I found ContextMenuFormulaBar which enables right click on formula bar and also in a cells inner (text etc.).
I have a excel file which contains several items in a custom ribbon. I've added these custom elements with Microsoft's "Custom UI Editor for Microsoft Office", my customization looks something like the following:
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<ribbon>
<tabs>
<tab id="XXX" label="XXX" insertAfterMso="TabInsert">
<group id="YYY" label="YYY">
<button id="btnXXX"
label="XXXX"
imageMso="PivotTableNewStyle"
size="large"
onAction="ZZZZ"
screentip="XXX"
supertip="XXX" />
</group>
</tab>
</tabs>
</ribbon>
</customUI>
I would like to modify(Add remove elements, change elements) this header with EPPlus, is this possible? If so how would it be done?
I have not found a way to do this in EPPlus, but I have found a way to edit it with the "DocumentFormat.OpenXml" library. Specifically to access that portion of the file I use the following code:
((SpreadsheetDocument)document.WorkbookPart.OpenXmlPackage).RibbonAndBackstageCustomizationsPart
I'm still not sure if it can be done in EPPlus. Maybe in a future version...
Is it possible to remove parts from the Ribbon, in VSTO Excel C# Document-Level Customizations?
For example, I want to disable the Data Tools group in the Ribbon.
Sure, you should be able to do
Create a new Excel Workbook project
Right click on solution - Add item = Ribbon XML
follow the steps in the newly generated class
edit the generated Ribbon.xml file like this
<?xml version="1.0" encoding="UTF-8"?>
<customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
<ribbon>
<tabs>
<tab idMso="TabData" visible="false">
</tab>
</tabs>
</ribbon>
</customUI>
When I run the project I can't see the Data tab in my Excel
I am developing a Power Point Add-in (Using C#) in which I have to add a Custom Menu Entry in the "File" Menu.
I followed all the steps in http://msdn.microsoft.com/en-us/library/bb608602(v=vs.100).aspx
but my menu is not showing up in Powerpoint.
Do I need to anything extra here ?
You must check i would my add-in to lad the host
Link of full sample : http://csharpmentor.blogspot.fr/2009/05/how-to-create-powerpoint-add-in-in-cnet.html
#Nilzor, I found the Solution, It is called Backstage view
We need to add the in the XML to make it work
<?xml version="1.0" encoding="utf-8"?>
<customUI onLoad="Ribbon_Load" xmlns="http://schemas.microsoft.com/office/2009/07/customui">
<backstage>
<tab id="MyBackstageTab"
label="My Tab"
getVisible="MyBackstageTab_GetVisible">
</tab>
</backstage>
</customUI>