简体   繁体   中英

c# Word-AddIn recognize ribbon-tab spelling

Different Word versions have different tab spelling. Some have the whole label as uppercase and others have just the first letter. I want know how I can recognize the spelling and change my tab label to the same case.

在此处输入图像描述

You already have an XML file containing your ribbon, right? If so, I think your best bet is just to go there, look for your tab element and manually change the text in the label attribute to all uppercase letters.
While it may not be a particularly elegant solution, it should do the job just fine. Only downside I can spot is that your ribbon will also appear in all caps if you go to 'Customize Ribbon' in the settings.

With this this.Application.Version you cab check the word version. The only thing I am doing then is checking if the version is older than 2013:

if (Convert.ToDouble(this.Application.Version) > 150)
{
    Globals.Ribbons.MyRibbon.WinWorker.Label = "lowercase";
}
else
{
    Globals.Ribbons.MyRibbon.WinWorker.Label = "UPPERCASE";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM