微软已经将拥有Office产品增进了Ribbon界面,微软曾经将全体Office产品丰硕了Ribbon界面

也有广大软件也推出了Ribbon界面,知名的如Autodesk种类、WinZip、Xencoder等:

Access 2010

Publisher 2010

Developer Audience

The
Windows Ribbon framework is designed for use by C/C++ developers and UI
designers.

Recommended
proficiencies:

  • COM
    programming
  • Windows
    API programming
  • XML/XAML
    programming

Recommended
foundational knowledge:

  • UI
    programming concepts
  • General UI
    concepts

图片 1

图片 2

图片 3

PowerPoint 2010

测试代码下载

Word 2010

小结

本次介绍了5种Office 2009Ribbon的开发方法,适合分化的人工宫外孕与须求。假如你的C++水平很高,且对Windows
API很纯熟,那么作者提出您选拔微软的Windows Ribbon
Framework,有官方帮忙,且效能很高。

本身个人更赞成于选择VSTO 4.0 + OpenXML SDK
2.0的点子,那样能够运用更熟练的技术来开发,便于系统持续升级、维护。Office
AddIn的章程处理起来万分复杂,要求展开过多说了算,若是您要求丰富高的自由度,建议使用此方法。至于最终一种商业组件,那属于有钱人了
:)
开个笑话。选拔哪个种类方案,具体应取决于业务需要,合适的才是最棒的。要是你有其余更好的方案,欢迎商量。

微软的Office体系办公套件从Office
二零零七始发第①遍引入了Ribbon导航菜单格局,其将一文山会海有关的机能集成在三个个Ribbon中,便于集中管理、操作。那种Ribbon是高度可定制的,用户能够将协调常用的功能拓展独立设置,升高级工程师作成效。不过由于Office
二〇〇二目前用户的操作习惯已经养成,结果到了Office
二〇〇七很多菜单、按钮都找不到了,着实有些狼狈。经过一段时间的适应,相信超越二分一用户已经习惯Ribbon式的界面了。到了Office
二零零六时日,微软一度将装有Office产品充分了Ribbon界面:

5、第叁方商业组件

当今有见怪不怪的控件、组件开发公司布署的软件也十一分好用,若是你的门类有雄厚的预算,能够考虑接纳那几个商业组件。

5.1、add-in-express

那是一家专门做插件的集团,官方主页:http://www.add-in-express.com

其出品线包涵:

图片 4

图片 5

图片 6

5、第壹方商业组件

后日有千千万万的控件、组件开发集团布置的软件也一定好用,假使您的花色有丰硕的预算,能够设想动用那些商业组件。

 

图片 7

图片 8

图片 9

 

InfoPath Designer 2010

PowerPoint 2010

Security Manager 2010 for Microsoft Outlook


 

 

add-in-express公司对Office的插件开发做了很好的包裹,大大简化了支出Office插件的进度,假诺您感兴趣,能够实行试用。

 

Add-in Express 2010 for Internet Explorer and Microsoft .net


 

SharePoint Workspace 2010(原Groove)

Word 2010

也有众多软件也推出了Ribbon界面,盛名的如Autodesk类别、WinZip、Xencoder等:

转发请注明出处:http://www.cnblogs.com/brooks-dotnet/archive/2010/12/31/1923519.html

图片 10

图片 11

小结

本次介绍了5种Office 二零一零Ribbon的开发方法,适合不相同的人工难产与须要。假若您的C++水平很高,且对Windows
API很熟稔,那么小编提出您使用微软的Windows Ribbon
Framework,有合法协理,且效用很高。

自小编个人更倾向于选拔VSTO 4.0 + OpenXML SDK
2.0的法门,那样能够采纳更熟知的技艺来支付,便于系统继续升级、维护。Office
AddIn的艺术处理起来分外复杂,要求实行过多操纵,要是你供给很是高的自由度,建议采用此格局。至于最后一种商业组件,那属于有钱人了
:)
开个玩笑。采取哪个种类方案,具体应取决于业务须要,合适的才是最棒的。假若您有任何更好的方案,欢迎斟酌。

Onenote 2010

图片 12

AutoCAD 2011

InfoPath Filler 2010

一、Windows Ribbon
Framework

Onenote 2010

Add-in Express 2010 for Microsoft Office and .net


 

Add-in Express 2010 for Microsoft Office and .net


 

Excel 2010

图片 13

图片 14

图片 15

Security Manager 2010 for Microsoft Outlook


 

 

add-in-express公司对Office的插件开发做了很好的卷入,大大简化了开发Office插件的长河,要是您感兴趣,能够展开试用。

 

图片 16

Access 2010

Excel 2010

图片 17

 

用作开发人士大家就想如何才能支付那种Ribbon界面。笔者查找了部分资料,整理如下,如若您有更好的方案,欢迎补充。

用作开发职员我们就想怎么着才能支付那种Ribbon界面。笔者寻找了有个别资料,整理如下,假使您有更好的方案,欢迎补充。

本种类具有示例代码均在 Visual Studio 二零零六 Ultimate 奥迪Q7TM + Office 贰零零捌Professional Plus KugaTM x64 中测试通过

一、Windows Ribbon
Framework

Minimum Requirements

Minimum supported client

Windows 7

Windows Vista with Service Pack 2 (SP2) and Platform Update for Windows Vista

Minimum supported server

Windows Server 2008 R2

Windows Server 2008 with SP2 and Platform Update for Windows Server 2008

Windows Software Development Kit (SDK)

7.0

Header and IDL files

uiribbon.h, uiribbon.idl

 

二、Office 2010
AddIns 

Office
PIA中提供了接口、类来对Ribbon实行操作,能够参见笔者事先的一篇博文:VSTO学习笔记(三)
开发Office 二零零六 61位COM加载项

最首要使用CommandBar类举行有关操作。利用Office
PIA操作Ribbon很不直观,须要控制很多细节,不过十分灵活,可以最大程度的自定义Ribbon。

 

三、OpenXML SDK 2.0

一经您还未曾安装OpenXML SDK 2.0,能够在这里下载。

Office
2006时日第①次推出了OpenXML格式,并且通过了ISO国际标准。OpenXML格式有为数不少便宜,微软也公布了OpenXML
SDK来对Office 200七 、Office 二零一零的文书档案进行操作,提供了除Office
PIA之外的另一种选取。选用OpenXML格式的Office文书档案实际上正是三个行业内部ZIP压缩包,能够将一个Office文书档案的扩充名修改为.zip并解压缩来查看里面包车型地铁始末。

用户自定的Ribbon在OpenXML中保存在二个名为customUI.xml的XML文件中,如图,小编打开了三个包罗有加载宏的Word
二〇〇九文书档案,在那之中有贰个自定义Ribbon,Office Developer Resources:

图片 18

将那么些文书档案的恢弘名修改为.zip:

图片 19

能够见到其文书档案结构,在customUI文件夹下保存了用户自定义Ribbon的音讯:

图片 20

打开customUI文件:

图片 21

能够看来用户自定义Ribbon的有血有肉描述,customUI.xml需求遵从Office
2009的XML架构正式,能够在这里下载。Office
2006的XML架构正式能够在这里下载。

下载下来解压缩后,是1个xsd文件,查找有关Ribbon的一部分:

图片 22

读书那些xsd文件须要有肯定的XML
Schema基础,大家只须求大概明白即可,首要为了前边添加自定义的customUI文件。OpenXML
SDK 2.0对此提供了协助,能够对Ribbon进行控制:

图片 23

上边大家给二个Word 二零一零的文书档案添加1个自定义Ribbon。

先是准备customUI.xml文件,写入如下内容:

<customUI
xmlns=’http://schemas.microsoft.com/office/2006/01/customui'&gt;

    <ribbon>

        <tabs>

            <tab id=’odcTab’ label=’Office
Developer Resources’ >

                <group id=’getStartedGrp’
label=’Getting Started’ >

                    <button id=’devCenterBtn’
label=’Office’ size=’normal’ image=’MSDN’
tag=’http://msdn.microsoft.com/en-us/office/default.aspx
onAction=’openPage’ screentip=’Learn about the possibilities offered by
the Microsoft Office system to develop solutions.’ />

                    <button id=’spBtn’
label=’SharePoint’ size=’normal’ image=’MSDN’
tag=’http://msdn.microsoft.com/en-us/sharepoint/default.aspx
onAction=’openPage’ screentip=’Helps teams stay connected and productive
by providing easy access to the people, documents, and information that
they need.’ />

                    <button id=’devMapBtn’
label=’Developer Map’ size=’normal’ imageMso=’ShowTimeZones’
tag=’http://msdn.microsoft.com/en-us/office/bb497969.aspx
onAction=’openPage’ screentip=’Helps you visualize the different
programs, servers, services, and tools that will help build Office
solutions.’ />

                </group>

                <group id=’productsGrp’
label=’Products and Technologies’ >

                    <button id=’officeSysBtn’
label=’Office System ‘ size=’normal’ image=’officesystem’
tag=’http://msdn.microsoft.com/en-us/office/aa905369.aspx
onAction=’openPage’ screentip=’A powerful collection of integrated
programs, servers, services, tools, and technologies.’ />

                    <gallery id=’productsGal’
label=’Products’ size=’normal’ imageMso=’SmartArtChangeColorsGallery’
onAction=’galOpenPage’ screentip=’Get the help and information you need
on each Office product.’ >

                        <item id=’Access’
label=’Access’ imageMso=’MicrosoftAccess’ />

                        <item id=’Excel’
label=’Excel’ imageMso=’MicrosoftExcel’ />

                        <item id=’InfoPath’
label=’InfoPath’ imageMso=’OpenInfopathForm’ />

                        <item id=’Outlook’
label=’Outlook’ imageMso=’MicrosoftOutlook’ />

                        <item id=’PowerPoint’
label=’PowerPoint’ imageMso=’MicrosoftPowerPoint’ />

                        <item id=’Project’
label=’Project’ imageMso=’MicrosoftProject’ />

                        <item id=’SPDesigner’
label=’SharePoint Designer’ imageMso=’AccessOnlineLists’/>

                        <item id=’SharePoint’
label=’SharePoint Server’ imageMso=’FileCreateDocumentWorkspace’
/>

                        <item id=’Visio’
label=’Visio’ imageMso=’TableExportTableToVisioPivotDiagram’
/>

                        <item id=’Word’
label=’Word’ imageMso=’ExportWord’ />

                    </gallery>

                    <gallery
id=’technologiesGal’ label=’Technologies’ imageMso=’PageMenu’
onAction=’galOpenPage’ screentip=’Learn about the technologies supported
by the Microsoft Office system.’ >

                        <item id=’OBA’
label=’OBA’ imageMso=’CreateClassModule’ />

                        <item id=’FluentUI’
label=’Office Fluent UI’ imageMso=’FormRegionMenu’
/>                    

                        <item id=’OpenXML’
label=’Open XML’ imageMso=’FileSaveAsCurrentFileFormat’ />

                        <item id=’VBA’
label=’VBA’ imageMso=’CreateModule’ />

                        <item id=’VSTO’
label=’VSTO’ image=’VSTO’ />

                    </gallery>

                </group>

                <group id=’libraryGrp’
label=’Library’ >

                    <button id=’offSysBtn’
label=’Office Development’ size=’normal’
imageMso=’AppointmentColorDialog’
tag=’http://msdn.microsoft.com/en-us/library/bb726436.aspx
onAction=’openPage’ screentip=’A set of helpful links to get you up to
speed on Office development.’ />

                    <button id=’spDevBtn’
label=’SharePoint Development’ size=’normal’
imageMso=’AccessOnlineLists’
tag=’http://msdn.microsoft.com/en-us/library/bb931739.aspx
onAction=’openPage’ screentip=’A set of helpful links to get you up to
speed on SharePoint products and technologies.’ />

                    <button id=’officeTalkBtn’
label=’Office Talk’ size=’normal’ imageMso=’MailSelectNames’
tag=’http://msdn.microsoft.com/en-us/library/bb660514(office.11).aspx
onAction=’openPage’ screentip=’Columns by long-time Office developers
and members of the Office Developer Documentation team.’ />

                </group>

                <group id=’learnGrp’
label=’Learn’ >

                    <button
id=’offDevelopmentBtn’ label=’Learn Office’ size=’normal’
imageMso=’AppointmentColorDialog’
tag=’http://msdn.microsoft.com/en-us/office/aa905375.aspx
onAction=’openPage’ screentip=’Explore this set of helpful links to get
you up-to-speed creating Office system solutions.’ />

                    <button
id=’sdkAndRefDocsBtn’ label=’SDKs and References’ size=’normal’
imageMso=’FunctionsLookupReferenceInsertGallery’
tag=’http://msdn.microsoft.com/en-us/office/aa905496.aspx
onAction=’openPage’ screentip=’Use these SDKs and developer references
to leverage your skills in creating rich Office and SharePoint
solutions.’ />

                    <button id=’booksdBtn’
label=’Books’ size=’normal’ imageMso=’VisualBasicReferences’
tag=’http://msdn.microsoft.com/en-us/office/dd537534.aspx
onAction=’openPage’ screentip=’Want to buy a book? Read a sample chapter
online? Visit this bookstore first.’ />

                    <button id=’howDoIBtn’
label=’How To Center’ size=’normal’ imageMso=’TentativeAcceptInvitation’
tag=’http://msdn.microsoft.com/en-us/office/bb266408.aspx
onAction=’openPage’ screentip=’Find over 200 how-to video demos, sample
code, and conceptual overviews.’ />

                    <button id=’videosBtn’
label=’Videos and Webcasts’ size=’normal’
imageMso=’SlideMasterMediaPlaceholderInsert’
tag=’http://msdn.microsoft.com/en-us/office/aa905350.aspx
onAction=’openPage’ screentip=’Need information quickly? No time to read
about it? Watch these videos.’ />

                    <button id=’channel9Btn’
label=’Channel 9′ size=’normal’ image=’Channel9′
tag=’http://channel9.msdn.com/tags/MS%20Office‘ onAction=’openPage’
screentip=’Channel 9 is a place for learning and sharing information,
created by developers for developers.’ />

                </group>

                <group id=’communityGrp’
label=’Community’ >

                    <button id=’communityBtn’
label=’Office Developers’ size=’normal’ imageMso=’OutlookGears’
tag=’http://msdn.microsoft.com/en-us/office/aa905341.aspx
onAction=’openPage’ screentip=’Check out the latest from the Office
developer community.’ />

                    <button id=’mvpBtn’
label=’MVP Content’ size=’normal’ imageMso=’MeetingsWorkspace’
tag=’http://msdn.microsoft.com/en-us/office/cc441428.aspx
onAction=’openPage’ screentip=’Take a look at the latest content
submitted by Office and SharePoint MVPs, third-parties, and experts in
the Office developer community.’ />

                    <button id=’codePlexBtn’
label=’CodePlex’ size=’normal’ image=’CodePlex’
tag=’http://www.codeplex.com/site/search?projectSearchText=office
onAction=’openPage’ screentip=’Provides you with access to a variety of
resources, including download areas, communication forums and product
information.’ />

                    <button id=’codeGalleryBtn’
label=’Code Gallery’ size=’normal’ image=’CodeGallery’
tag=’http://code.msdn.microsoft.com/Project/ProjectDirectory.aspx?ProjectSearchText=office
onAction=’openPage’ screentip=’Download and share sample applications,
code snippets, and other resources with the developer community.’
/>

                    <button id=’facebookBtn’
label=’facebook’ size=’normal’ image=’facebook’
tag=’http://www.facebook.com/group.php?gid=51196093535
onAction=’openPage’ screentip=’A place for comments, questions, and
answers about development with Office products.’ />

                    <button id=’twitterBtn’
label=’Twitter’ size=’normal’ image=’twitter’
tag=’http://twitter.com/MSDN\_Office‘ onAction=’openPage’
screentip=’Follow what is currently happening with Microsoft Office
development.’ />

                </group>

                <group id=’supportGrp’
label=’Forums and Support’ >

                    <button id=’forumsBtn’
label=’Forums’ size=’normal’ imageMso=’WorkgroupAdmin’
tag=’http://social.msdn.microsoft.com/Forums/en-US/category/officedev,oldevelopment,sharepoint,uc/
onAction=’openPage’ screentip=’Get your questions answered by experts in
their respective Office products.’ />

                    <button id=’newsgroupBtn’
label=’Newsgroups’ size=’normal’ imageMso=’FileCreateDocumentWorkspace’
tag=’http://msdn.microsoft.com/en-us/office/aa905346.aspx
onAction=’openPage’ screentip=’Ask questions, share information, or
exchange ideas with others, including experts from around the globe.’
/>

                    <button id=’supportBtn’
label=’Support’ size=’normal’ imageMso=’ControlsGallery’
tag=’http://msdn.microsoft.com/en-us/office/aa905515.aspx
onAction=’openPage’ screentip=’Search to find a resource, ask a question
in the forums, or contact Microsoft support for help.’ />

                </group>

            </tab>

        </tabs>

    </ribbon>

</customUI>

 

专注为了防止转义,全体应用了单引号。

使用OpenXML SDK 2.0添加此Ribbon:

 

图片 24图片 25使用OpenXML SDK 2.0添加此Ribbon:

        private void fnAddRibbon(string v_strWordPath, string v_strCustomerXML)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(v_strWordPath, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;

                if (myDoc.GetPartsCountOfType<RibbonExtensibilityPart>() > 0)
                    myDoc.DeletePart(myDoc.GetPartsOfType<RibbonExtensibilityPart>().First());

                RibbonExtensibilityPart ribbonExtensibilityPart = myDoc.AddNewPart<RibbonExtensibilityPart>();
                ribbonExtensibilityPart.CustomUI = new DocumentFormat.OpenXml.Office.CustomUI.CustomUI(v_strCustomerXML);
            }
        }

 

 

  

运转后得以看到Word中冒出了二个自定义Ribbon:

图片 26

本条自定义Ribbon笔者取自MSDN上的一篇博客,原来的作品地址。下边包车型的士那一个事例就来源于那篇博客,作者对其进展了区区改动。

注:小编写此Demo时使用的OpenXML
SDK版本较老,导致在OpenXML SDK
2.0下编写翻译失利,经查是1个类的继续关系做了改动,笔者曾经做了改进。

德姆o2:将1个文书档案中的Ribbon复制到另2个文书档案中。

 

图片 27图片 28将二个文书档案中的Ribbon复制到另1个文书档案中

        static void AddCustomUIParts(string filename, RibbonExtensibilityPart customRibbonPart, OpenXmlPart vbaPart)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(filename, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;

                if (myDoc.GetPartsCountOfType<RibbonExtensibilityPart>() > 0)
                    myDoc.DeletePart(myDoc.GetPartsOfType<RibbonExtensibilityPart>().First());

                myDoc.AddPart<RibbonExtensibilityPart>(customRibbonPart);

                OpenXmlPart extendedPart = null;

                foreach (IdPartPair partPair in mainPart.Parts)
                {
                    if (partPair.OpenXmlPart.RelationshipType == “http://schemas.microsoft.com/office/2006/relationships/vbaProject“)
                    {
                        extendedPart = partPair.OpenXmlPart;
                        break;
                    }
                }

                if (extendedPart != null)
                    mainPart.DeletePart(extendedPart);

                if (vbaPart != null)
                    mainPart.AddPart<OpenXmlPart>(vbaPart);
            }
        }

        static void ImportCustomUI(string templateFile, string outputFile)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(templateFile, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;

                RibbonExtensibilityPart customRibbonPart = myDoc.GetPartsOfType<RibbonExtensibilityPart>().First();
                OpenXmlPart vbaPart = null;

                foreach (IdPartPair partPair in mainPart.Parts)
                {
                    if (partPair.OpenXmlPart.RelationshipType == “http://schemas.microsoft.com/office/2006/relationships/vbaProject“)
                    {
                        //vbaPart = (ExtendedPart)partPair.OpenXmlPart;
                        vbaPart = partPair.OpenXmlPart;
                        break;
                    }
                }

                AddCustomUIParts(outputFile, customRibbonPart, vbaPart);
                ChangeDocumentType(outputFile);
            }
        }

        static void ChangeDocumentType(string filename)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(filename, true))
            {
                myDoc.ChangeDocumentType(WordprocessingDocumentType.MacroEnabledDocument);                
            }

            //注意因为含有了宏,必供给保存为.docm格式。
            string newFileName = Path.GetDirectoryName(filename) + @”\” + Path.GetFileNameWithoutExtension(filename) + “(was docx).docm”;

            File.Move(filename, newFileName);
            File.Delete(filename);
        }

 

 

  

运作结果:

图片 29

 

Alt + F11 打开VBA 7.0的编辑器,能够看到Ribbon中的事件处理函数:

图片 30

函数的效能非常的粗略,是当点击Ribbon中的按钮时跳转到钦点网站,约等于一个浏览器收藏夹的成效。

 

四、VSTO 4.0 Ribbon
Controls

安装Visual Studio 2009的Office开发工具后,就足以行使VSTO
4.0来便宜的展开Office开发了。

如图小编建立了八个Excel 二〇〇九 Workbook项目,Add
Item时有叁个可视化Ribbon的选项:

图片 31

增进其后就足以像开发Windows
Form一样设计Ribbon,同时工具箱中叶现身了Office Ribbon Controls:

图片 32

如上海体育场所所示,作者添加了一个Tab,分了陆个组,每一个组中添加了图标按钮,Excel中添加了叁个Web
Browser控件,当点击相应按钮时Web Browser跳转到各自类型官方网站:

 

图片 33图片 34代码

        private Ribbon1 ribbon = new Ribbon1();

        void btnDF_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://www.documentfoundation.org/“);
        }

        void btnOracle_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://www.openoffice.org/“);
        }

        void btnOffice2010_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://office.microsoft.com/zh-cn/“);
        }

        void btnGoogleDocs_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://docs.google.com/“);
        }

        private void Sheet1_Startup(object sender, System.EventArgs e)
        {
            Globals.Ribbons.Ribbon1.btnDF.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnDF_Click);
            Globals.Ribbons.Ribbon1.btnGoogleDocs.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnGoogleDocs_Click);
            Globals.Ribbons.Ribbon1.btnOffice2010.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnOffice2010_Click);
            Globals.Ribbons.Ribbon1.btnOracle.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnOracle_Click);
        }

 

 

  

运转结果:

图片 35

图片 36

图片 37

图片 38

 

Ribbon补助右键导出为XML,即上文提到的customUI.xml:

图片 39

点击导出为XML后会自动生成三个文件:

图片 40

XML文件的始末格式符合Office 2008 XML架构正式:

图片 41

 

测试代码下载

微软的Office体系办公套件从Office
2006发端第三回引入了Ribbon导航菜单方式,其将一多样相关的效果集成在四个个Ribbon中,便于集中管理、操作。那种Ribbon是惊人可定制的,用户能够将协调常用的效应拓展独立设置,升高级工程师作作用。可是由于Office
二〇〇一时日用户的操作习惯已经养成,结果到了Office
二〇〇五很多菜单、按钮都找不到了,着实某个窘迫。经过一段时间的适应,相信半数以上用户已经不乏先例Ribbon式的界面了。到了Office
二〇一〇时期,微软曾经将全部Office产品丰盛了Ribbon界面:

Visio 2010

InfoPath Designer 2010

图片 42

图片 43

AutoCAD 2011

 

 

5.2、devcomponents

这家铺子的业务范围稍微大了有的,官方主页:http://www.devcomponents.com/

其重要为Windows Forms、WPF、Silverlight设计Ribbon界面,产品线包含:

DotNetBar for Windows
Forms

DotNetBar for
Silverlight

DotNetBar for
WPF

Professional Icon
Pack

Essential Icon
Pack

HTML-Document
Component

HTML Help COM
Assistant
(免费)

 

转发请申明出处:http://www.cnblogs.com/brooks-dotnet/archive/2010/12/31/1923519.html

图片 44

5.2、devcomponents

这家公司的业务范围稍微大了一些,官方主页:http://www.devcomponents.com/

其首要为Windows Forms、WPF、Silverlight设计Ribbon界面,产品线蕴涵:

DotNetBar for Windows
Forms

DotNetBar for
Silverlight

DotNetBar for
WPF

Professional Icon
Pack

Essential Icon
Pack

HTML-Document
Component

HTML Help COM
Assistant
(免费)

 

InfoPath Filler 2010

Add-in Express 2010 for Internet Explorer and Microsoft .net


 

Visio 2010

本连串具有示例代码均在 Visual Studio 2008 Ultimate EvoqueTM + Office 二〇一〇Professional Plus 奔驰M级TM x64 中测试通过

 

 

图片 45

以下摘自MSDN,原稿地址.aspx)

Project 2010

图片 46

图片 47

Minimum Requirements

Minimum supported client

Windows 7

Windows Vista with Service Pack 2 (SP2) and Platform Update for Windows Vista

Minimum supported server

Windows Server 2008 R2

Windows Server 2008 with SP2 and Platform Update for Windows Server 2008

Windows Software Development Kit (SDK)

7.0

Header and IDL files

uiribbon.h, uiribbon.idl

 

二、Office 2010
AddIns 

Office
PIA中提供了接口、类来对Ribbon进行操作,能够参见作者前边的一篇博文:VSTO读书笔记(三)
开发Office 二零零六 陆10位COM加载项

第③采用CommandBar类实行相关操作。利用Office
PIA操作Ribbon很不直观,要求控制很多细节,不过相当灵活,能够最大程度的自定义Ribbon。

 

三、OpenXML SDK 2.0

即使您还向来不设置OpenXML SDK 2.0,能够在这里下载。

Office
2006时代首次生产了OpenXML格式,并且经过了ISO国际标准。OpenXML格式有无数利益,微软也揭橥了OpenXML
SDK来对Office 200七 、Office 二零零六的文书档案实行操作,提供了除Office
PIA之外的另一种选择。选用OpenXML格式的Office文档实际上正是贰个专业ZIP压缩包,可以将2个Office文书档案的恢弘名修改为.zip并解压缩来查阅里面包车型大巴剧情。

用户自定的Ribbon在OpenXML中保留在一个名为customUI.xml的XML文件中,如图,笔者打开了1个分包有加载宏的Word
二〇〇八文书档案,当中有3个自定义Ribbon,Office Developer Resources:

图片 48

将以此文书档案的扩展名修改为.zip:

图片 49

能够见见其文档结构,在customUI文件夹下保存了用户自定义Ribbon的新闻:

图片 50

打开customUI文件:

图片 51

能够看出用户自定义Ribbon的切切实实讲述,customUI.xml必要服从Office
二零零六的XML框架结构正式,能够在这里下载。Office
二〇〇七的XML架构正式能够在这里下载。

下载下来解压缩后,是一个xsd文件,查找有关Ribbon的局地:

图片 52

开卷这几个xsd文件须求有必然的XML
Schema基础,大家只供给大概掌握即可,主要为了后边添加自定义的customUI文件。OpenXML
SDK 2.0对此提供了支撑,能够对Ribbon进行支配:

图片 53

上边大家给二个Word 二零零六的文档添加1个自定义Ribbon。

先是准备customUI.xml文件,写入如下内容:

<customUI
xmlns=’http://schemas.microsoft.com/office/2006/01/customui'&gt;

    <ribbon>

        <tabs>

            <tab id=’odcTab’ label=’Office
Developer Resources’ >

                <group id=’getStartedGrp’
label=’Getting Started’ >

                    <button id=’devCenterBtn’
label=’Office’ size=’normal’ image=’MSDN’
tag=’http://msdn.microsoft.com/en-us/office/default.aspx
onAction=’openPage’ screentip=’Learn about the possibilities offered by
the Microsoft Office system to develop solutions.’ />

                    <button id=’spBtn’
label=’SharePoint’ size=’normal’ image=’MSDN’
tag=’http://msdn.microsoft.com/en-us/sharepoint/default.aspx
onAction=’openPage’ screentip=’Helps teams stay connected and productive
by providing easy access to the people, documents, and information that
they need.’ />

                    <button id=’devMapBtn’
label=’Developer Map’ size=’normal’ imageMso=’ShowTimeZones’
tag=’http://msdn.microsoft.com/en-us/office/bb497969.aspx
onAction=’openPage’ screentip=’Helps you visualize the different
programs, servers, services, and tools that will help build Office
solutions.’ />

                </group>

                <group id=’productsGrp’
label=’Products and Technologies’ >

                    <button id=’officeSysBtn’
label=’Office System ‘ size=’normal’ image=’officesystem’
tag=’http://msdn.microsoft.com/en-us/office/aa905369.aspx
onAction=’openPage’ screentip=’A powerful collection of integrated
programs, servers, services, tools, and technologies.’ />

                    <gallery id=’productsGal’
label=’Products’ size=’normal’ imageMso=’SmartArtChangeColorsGallery’
onAction=’galOpenPage’ screentip=’Get the help and information you need
on each Office product.’ >

                        <item id=’Access’
label=’Access’ imageMso=’MicrosoftAccess’ />

                        <item id=’Excel’
label=’Excel’ imageMso=’MicrosoftExcel’ />

                        <item id=’InfoPath’
label=’InfoPath’ imageMso=’OpenInfopathForm’ />

                        <item id=’Outlook’
label=’Outlook’ imageMso=’MicrosoftOutlook’ />

                        <item id=’PowerPoint’
label=’PowerPoint’ imageMso=’MicrosoftPowerPoint’ />

                        <item id=’Project’
label=’Project’ imageMso=’MicrosoftProject’ />

                        <item id=’SPDesigner’
label=’SharePoint Designer’ imageMso=’AccessOnlineLists’/>

                        <item id=’SharePoint’
label=’SharePoint Server’ imageMso=’FileCreateDocumentWorkspace’
/>

                        <item id=’Visio’
label=’Visio’ imageMso=’TableExportTableToVisioPivotDiagram’
/>

                        <item id=’Word’
label=’Word’ imageMso=’ExportWord’ />

                    </gallery>

                    <gallery
id=’technologiesGal’ label=’Technologies’ imageMso=’PageMenu’
onAction=’galOpenPage’ screentip=’Learn about the technologies supported
by the Microsoft Office system.’ >

                        <item id=’OBA’
label=’OBA’ imageMso=’CreateClassModule’ />

                        <item id=’FluentUI’
label=’Office Fluent UI’ imageMso=’FormRegionMenu’
/>                    

                        <item id=’OpenXML’
label=’Open XML’ imageMso=’FileSaveAsCurrentFileFormat’ />

                        <item id=’VBA’
label=’VBA’ imageMso=’CreateModule’ />

                        <item id=’VSTO’
label=’VSTO’ image=’VSTO’ />

                    </gallery>

                </group>

                <group id=’libraryGrp’
label=’Library’ >

                    <button id=’offSysBtn’
label=’Office Development’ size=’normal’
imageMso=’AppointmentColorDialog’
tag=’http://msdn.microsoft.com/en-us/library/bb726436.aspx
onAction=’openPage’ screentip=’A set of helpful links to get you up to
speed on Office development.’ />

                    <button id=’spDevBtn’
label=’SharePoint Development’ size=’normal’
imageMso=’AccessOnlineLists’
tag=’http://msdn.microsoft.com/en-us/library/bb931739.aspx
onAction=’openPage’ screentip=’A set of helpful links to get you up to
speed on SharePoint products and technologies.’ />

                    <button id=’officeTalkBtn’
label=’Office Talk’ size=’normal’ imageMso=’MailSelectNames’
tag=’http://msdn.microsoft.com/en-us/library/bb660514(office.11).aspx
onAction=’openPage’ screentip=’Columns by long-time Office developers
and members of the Office Developer Documentation team.’ />

                </group>

                <group id=’learnGrp’
label=’Learn’ >

                    <button
id=’offDevelopmentBtn’ label=’Learn Office’ size=’normal’
imageMso=’AppointmentColorDialog’
tag=’http://msdn.microsoft.com/en-us/office/aa905375.aspx
onAction=’openPage’ screentip=’Explore this set of helpful links to get
you up-to-speed creating Office system solutions.’ />

                    <button
id=’sdkAndRefDocsBtn’ label=’SDKs and References’ size=’normal’
imageMso=’FunctionsLookupReferenceInsertGallery’
tag=’http://msdn.microsoft.com/en-us/office/aa905496.aspx
onAction=’openPage’ screentip=’Use these SDKs and developer references
to leverage your skills in creating rich Office and SharePoint
solutions.’ />

                    <button id=’booksdBtn’
label=’Books’ size=’normal’ imageMso=’VisualBasicReferences’
tag=’http://msdn.microsoft.com/en-us/office/dd537534.aspx
onAction=’openPage’ screentip=’Want to buy a book? Read a sample chapter
online? Visit this bookstore first.’ />

                    <button id=’howDoIBtn’
label=’How To Center’ size=’normal’ imageMso=’TentativeAcceptInvitation’
tag=’http://msdn.microsoft.com/en-us/office/bb266408.aspx
onAction=’openPage’ screentip=’Find over 200 how-to video demos, sample
code, and conceptual overviews.’ />

                    <button id=’videosBtn’
label=’Videos and Webcasts’ size=’normal’
imageMso=’SlideMasterMediaPlaceholderInsert’
tag=’http://msdn.microsoft.com/en-us/office/aa905350.aspx
onAction=’openPage’ screentip=’Need information quickly? No time to read
about it? Watch these videos.’ />

                    <button id=’channel9Btn’
label=’Channel 9′ size=’normal’ image=’Channel9′
tag=’http://channel9.msdn.com/tags/MS%20Office‘ onAction=’openPage’
screentip=’Channel 9 is a place for learning and sharing information,
created by developers for developers.’ />

                </group>

                <group id=’communityGrp’
label=’Community’ >

                    <button id=’communityBtn’
label=’Office Developers’ size=’normal’ imageMso=’OutlookGears’
tag=’http://msdn.microsoft.com/en-us/office/aa905341.aspx
onAction=’openPage’ screentip=’Check out the latest from the Office
developer community.’ />

                    <button id=’mvpBtn’
label=’MVP Content’ size=’normal’ imageMso=’MeetingsWorkspace’
tag=’http://msdn.microsoft.com/en-us/office/cc441428.aspx
onAction=’openPage’ screentip=’Take a look at the latest content
submitted by Office and SharePoint MVPs, third-parties, and experts in
the Office developer community.’ />

                    <button id=’codePlexBtn’
label=’CodePlex’ size=’normal’ image=’CodePlex’
tag=’http://www.codeplex.com/site/search?projectSearchText=office
onAction=’openPage’ screentip=’Provides you with access to a variety of
resources, including download areas, communication forums and product
information.’ />

                    <button id=’codeGalleryBtn’
label=’Code Gallery’ size=’normal’ image=’CodeGallery’
tag=’http://code.msdn.microsoft.com/Project/ProjectDirectory.aspx?ProjectSearchText=office
onAction=’openPage’ screentip=’Download and share sample applications,
code snippets, and other resources with the developer community.’
/>

                    <button id=’facebookBtn’
label=’facebook’ size=’normal’ image=’facebook’
tag=’http://www.facebook.com/group.php?gid=51196093535
onAction=’openPage’ screentip=’A place for comments, questions, and
answers about development with Office products.’ />

                    <button id=’twitterBtn’
label=’Twitter’ size=’normal’ image=’twitter’
tag=’http://twitter.com/MSDN\_Office‘ onAction=’openPage’
screentip=’Follow what is currently happening with Microsoft Office
development.’ />

                </group>

                <group id=’supportGrp’
label=’Forums and Support’ >

                    <button id=’forumsBtn’
label=’Forums’ size=’normal’ imageMso=’WorkgroupAdmin’
tag=’http://social.msdn.microsoft.com/Forums/en-US/category/officedev,oldevelopment,sharepoint,uc/
onAction=’openPage’ screentip=’Get your questions answered by experts in
their respective Office products.’ />

                    <button id=’newsgroupBtn’
label=’Newsgroups’ size=’normal’ imageMso=’FileCreateDocumentWorkspace’
tag=’http://msdn.microsoft.com/en-us/office/aa905346.aspx
onAction=’openPage’ screentip=’Ask questions, share information, or
exchange ideas with others, including experts from around the globe.’
/>

                    <button id=’supportBtn’
label=’Support’ size=’normal’ imageMso=’ControlsGallery’
tag=’http://msdn.microsoft.com/en-us/office/aa905515.aspx
onAction=’openPage’ screentip=’Search to find a resource, ask a question
in the forums, or contact Microsoft support for help.’ />

                </group>

            </tab>

        </tabs>

    </ribbon>

</customUI>

 

在意为了制止转义,全体选取了单引号。

使用OpenXML SDK 2.0添加此Ribbon:

 

图片 54图片 55使用OpenXML SDK 2.0添加此Ribbon:

        private void fnAddRibbon(string v_strWordPath, string v_strCustomerXML)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(v_strWordPath, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;

                if (myDoc.GetPartsCountOfType<RibbonExtensibilityPart>() > 0)
                    myDoc.DeletePart(myDoc.GetPartsOfType<RibbonExtensibilityPart>().First());

                RibbonExtensibilityPart ribbonExtensibilityPart = myDoc.AddNewPart<RibbonExtensibilityPart>();
                ribbonExtensibilityPart.CustomUI = new DocumentFormat.OpenXml.Office.CustomUI.CustomUI(v_strCustomerXML);
            }
        }

 

 

  

运作后方可观望Word中冒出了1个自定义Ribbon:

图片 56

这么些自定义Ribbon作者取自MSDN上的一篇博客,原稿地址。上边包车型大巴那么些事例就来自那篇博客,小编对其进展了一定量修改。

注:笔者写此德姆o时使用的OpenXML
SDK版本较老,导致在OpenXML SDK
2.0下编写翻译失利,经查是一个类的三番五次关系做了变更,小编一度做了修正。

德姆o2:将1个文书档案中的Ribbon复制到另二个文书档案中。

 

图片 57图片 58将八个文档中的Ribbon复制到另三个文档中

        static void AddCustomUIParts(string filename, RibbonExtensibilityPart customRibbonPart, OpenXmlPart vbaPart)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(filename, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;

                if (myDoc.GetPartsCountOfType<RibbonExtensibilityPart>() > 0)
                    myDoc.DeletePart(myDoc.GetPartsOfType<RibbonExtensibilityPart>().First());

                myDoc.AddPart<RibbonExtensibilityPart>(customRibbonPart);

                OpenXmlPart extendedPart = null;

                foreach (IdPartPair partPair in mainPart.Parts)
                {
                    if (partPair.OpenXmlPart.RelationshipType == “http://schemas.microsoft.com/office/2006/relationships/vbaProject“)
                    {
                        extendedPart = partPair.OpenXmlPart;
                        break;
                    }
                }

                if (extendedPart != null)
                    mainPart.DeletePart(extendedPart);

                if (vbaPart != null)
                    mainPart.AddPart<OpenXmlPart>(vbaPart);
            }
        }

        static void ImportCustomUI(string templateFile, string outputFile)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(templateFile, true))
            {
                MainDocumentPart mainPart = myDoc.MainDocumentPart;

                RibbonExtensibilityPart customRibbonPart = myDoc.GetPartsOfType<RibbonExtensibilityPart>().First();
                OpenXmlPart vbaPart = null;

                foreach (IdPartPair partPair in mainPart.Parts)
                {
                    if (partPair.OpenXmlPart.RelationshipType == “http://schemas.microsoft.com/office/2006/relationships/vbaProject“)
                    {
                        //vbaPart = (ExtendedPart)partPair.OpenXmlPart;
                        vbaPart = partPair.OpenXmlPart;
                        break;
                    }
                }

                AddCustomUIParts(outputFile, customRibbonPart, vbaPart);
                ChangeDocumentType(outputFile);
            }
        }

        static void ChangeDocumentType(string filename)
        {
            using (WordprocessingDocument myDoc = WordprocessingDocument.Open(filename, true))
            {
                myDoc.ChangeDocumentType(WordprocessingDocumentType.MacroEnabledDocument);                
            }

            //注意因为含有了宏,必供给保留为.docm格式。
            string newFileName = Path.GetDirectoryName(filename) + @”\” + Path.GetFileNameWithoutExtension(filename) + “(was docx).docm”;

            File.Move(filename, newFileName);
            File.Delete(filename);
        }

 

 

  

运维结果:

图片 59

 

Alt + F11 打开VBA 7.0的编辑器,能够观看Ribbon中的事件处理函数:

图片 60

函数的效益很不难,是当点击Ribbon中的按钮时跳转到钦点网站,相当于两个浏览器收藏夹的法力。

 

四、VSTO 4.0 Ribbon
Controls

设置Visual Studio 二〇一〇的Office开发工具后,就足以应用VSTO
4.0来方便的进展Office开发了。

如图作者建立了1个Excel 二零零六 Workbook项目,Add
Item时有一个可视化Ribbon的选项:

图片 61

加上随后就足以像开发Windows
Form一样设计Ribbon,同时工具箱中叶出现了Office Ribbon Controls:

图片 62

如上海教室所示,笔者添加了贰个Tab,分了多少个组,各样组中添加了图标按钮,Excel中添加了一个Web
Browser控件,当点击相应按钮时Web Browser跳转到各自项目官方网站:

 

图片 63图片 64代码

        private Ribbon1 ribbon = new Ribbon1();

        void btnDF_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://www.documentfoundation.org/“);
        }

        void btnOracle_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://www.openoffice.org/“);
        }

        void btnOffice2010_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://office.microsoft.com/zh-cn/“);
        }

        void btnGoogleDocs_Click(object sender, Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs e)
        {
            this.wbIE.Navigate(“http://docs.google.com/“);
        }

        private void Sheet1_Startup(object sender, System.EventArgs e)
        {
            Globals.Ribbons.Ribbon1.btnDF.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnDF_Click);
            Globals.Ribbons.Ribbon1.btnGoogleDocs.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnGoogleDocs_Click);
            Globals.Ribbons.Ribbon1.btnOffice2010.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnOffice2010_Click);
            Globals.Ribbons.Ribbon1.btnOracle.Click += new Microsoft.Office.Tools.Ribbon.RibbonControlEventHandler(btnOracle_Click);
        }

 

 

  

运作结果:

图片 65

图片 66

图片 67

图片 68

 

Ribbon协理右键导出为XML,即上文提到的customUI.xml:

图片 69

点击导出为XML后会自动生成四个文本:

图片 70

XML文件的剧情格式符合Office 二零一零 XML架构正式:

图片 71

 

以下摘自MSDN,原稿地址.aspx)

Project 2010

Developer Audience

The
Windows Ribbon framework is designed for use by C/C++ developers and UI
designers.

Recommended
proficiencies:

  • COM
    programming
  • Windows
    API programming
  • XML/XAML
    programming

Recommended
foundational knowledge:

  • UI
    programming concepts
  • General UI
    concepts

图片 72

5.1、add-in-express

那是一家专门做插件的商户,官方主页:http://www.add-in-express.com

其产品线包含:

Publisher 2010

Add-in Express 2010 for Microsoft Office and CodeGear VCL


 

 

SharePoint Workspace 2010(原Groove)

Add-in Express 2010 for Microsoft Office and CodeGear VCL