- Mohankumar Devasigamani
Hope readers might
have gone through my previous post which helps you to better understand on how to create MS Office add-ins.
Note: As per
my previous blog post, I sticked on MS Visual Studio 2010 & MS
Office 2010.
Adding Reference to the project
- Open MS Office add-in project (CSSSampleAddin)
- Right-click on Reference folder in add-in project ->Go to Add Reference
- Add Reference window will appear.
Creating the
Ribbon menu Customization XML File
- Right-click on project -> Add -> New Item
- Select XML file and name it as RibbonMenu.xml ->Click Add
- Edit and add the below XML content to the XML file.
<?xml
version="1.0"
encoding="utf-8"
?>
<customUI
xmlns=http://schemas.microsoft.com/office/2006/01/customui loadImage="GetImage">
<ribbon>
<tabs>
<tab
id="tab1"
label="CSS
Corp Demo">
<group
id="group1"
label="CSS
Group">
<menu
id="menu1"
label="Drop
Down"
itemSize="large"
getScreentip="GetScreenTip"
supertip="This
is a super tip
for
the menu."
image="star">
<button
id="uxSearchButton"
image="search"
getDescription="GetDescription"
</menu>
</group>
</tab>
</tabs>
</ribbon>
</customUI>
- Save the file.
Set the
RibbonMenu.xml as embedded resource
- Right-click on the RibbonMenu.xml file -> Properties
- Change Build Action property to Embedded Resource
- Go to CSSSampleAddin project properties -> Select Resource tab
- Select file option, and drag and drop the xml file -> Save the properties
Start writing the
code
Open Connect.cs and
add below lines in top of the class file
using Microsoft.Office.Core;
using
Word = Microsoft.Office.Interop.Word;
Create instance of
Word and implement the IRibbonExtensibility
interface.
Edit / Modify the existing code as below
private
Word.Application
applicationObject;
Edit /Modify the
first line of OnConnection() method as below
applicationObject
= (Word.Application)application;
Inherited the
IRibbonExtensibility
in Connect class
public
class
Connect
: Object,
Extensibility.IDTExtensibility2,
IRibbonExtensibility
Right-click on
implemented interface and click Implement Interface, and then click
Implement Interface Explicitly that will add
IRibbonExtensibility.GetCustomUI
method. Add the below line GetCustimUI method.
return
Properties.Resources.Ribbon;
Now almost your demo
add-in is ready for test. Before testing add the image for custom
ribbon menu.
Adding your own
image file
- Right-click on project -> Add -> New Item
- Select Bitmap file ->Browse your image -> Click Add
- To embed the image, please follow the same steps that we did for XML file.
For example here i
have added two images named search and star. You can see those two
images below .
Add the below
method in connect class
public
IPictureDisp
GetImage(string
imageName)
{
IPictureDisp
dispImage = null;
switch
(imageName)
{
case
"search":
dispImage
= PictureConverter.ImageToPictureDisp
(Properties.Resources.search);
break;
case
"star":
dispImage
= PictureConverter.ImageToPictureDisp
(Properties.Resources.star);
break;
}
return
dispImage;
}
Include the below
class in the same file.
internal
class
PictureConverter
: AxHost
{
private
PictureConverter() : base(String.Empty)
{ }
static
public
IPictureDisp
ImageToPictureDisp(Image
image)
{
return
(IPictureDisp)GetIPictureDispFromPicture(image);
}
static
public
IPictureDisp
IconToPictureDisp(Icon
icon)
{
return
ImageToPictureDisp(icon.ToBitmap());
}
static
public
Image
PictureDispToImage(IPictureDisp
picture)
{
return
GetPictureFromIPicture(picture);
}
}
GetImage
method will be already referred from RibbonMenu.xml file.
Right time to test
demo project. Build the CSSSampleAddin project. Go to project
properties Select Debug and set
Start external program to Word,
by default word exe located in C:\Program
Files\Microsoft Office\Office14\WINWORD.EXE
Run the add-in
project, you will be able to see the customized Ribbon menu.
Write the method
to handle click event of Search button.
public
void
Search(Microsoft.Office.Core.IRibbonControl
control)
{
MessageBox.Show("User
has clicked Search button.",
"CSS
Corp Demo");
}
I hope this post helped you to know how ribbon menu can be added to Microsoft Word. Similarly the same process can be used to add ribbon menu to any of the Microsoft Word Office tools (Excel,Access etc.) As I mentioned
in my previous blog. In Further you can setup project to create msi
/exe which will help you to create add-in in other machine.
Note: Await and stay tuned for my next post "List to be checked out while MS Office add-ins are not getting loaded".
25 comments:
how to install microsoft office 14.0 object library.. please help me.. its urgent
I will check it that how it is done, i can guess from post that it will work.
C# Customize ribbon menu for MS Office
Talking about helpful info, you should definitely check this out. Here you can order an academic essay if you need.
Thanks for all the tips mentioned in this article! it’s always good to read things you have heard before and are implementing, but from a different perspective, always pick up some extra bits of information. Visit@
mcafee.com/activate
Thanks for all the tips mentioned in this article! it’s always good to read things you have heard before and are implementing, but from a different perspective, always pick up some extra bits of information. Visit@
norton.com/setup
office.com/setup
office.com/setup
mcafee.com/activate
Air Canada Book A Flight Thanks for the nice blog. It was very useful for me. I’m happy I found this blog. Thank you for sharing with us,I too always learn something new from your post.
garmin express is a special application designed by Garmin to manage Garmin devices. This incredible app is used for map updates, device registration, software updates and syncing of fitness data with Garmin Connect. However, the services are not confined to these, but there are many more that you can do with the help of Garmin Express. However, that depends upon the status of Garmin Express, whether it is up-to-date or not because if it is not, then you won’t be able to enjoy all the aforementioned benefits.
Simply placed, via the Internet, Roku enables you to watch free and paid video content on your TV. Roku is the number 1 streaming device common in the United Kingdom and the United States.
roku.com/link
Garmin is a program that handles the complete updating of the Mac windows. It syncs the device and links the device to your PC. Garmin.com/express will immediately refresh your PC with the new map. It even lets you know about the latest releases.
Garmin is a program that handles the complete updating of the Mac windows. It syncs the device and links the device to your PC. www.Garmin.com/express will immediately refresh your PC with the new map. It even lets you know about the latest releases.
Roku activation code is a code meant to activate the software and confirm that when you are finished with the Roku activation process, you can add multiple streaming services like Netflix, HBO, NBC and many more .
Roku com link
Garmin Express is an application designed to manage Garmin devices. It is used for app registration, software upgrades and map changes, garmin express Exercise data synchronization, and many more. Garmin Express, choose your computer’s operating system below: Windows or Mac. In order to Download and Install Garmin Express Software on your device.
Roku.com/link is a package of entertainment. The Roku channel is the Expansion of programming for new generation children. Roku declares plans to Combined kids and family movies and TV together with the channel’s other content, including subscriptions, its free, television, ad-supported movies, and live TV.
roku.com/link
McAfee is an antivirus program that helps user to fight against unwanted infection. To protect computer and network user should have an antivirus installed on their computer or laptop.
25 digit McAfee activation code
Amazon Prime Video is a streaming service that allows you to watch movies, web series, TV episodes, and other content on demand. It also offers hundreds of thousands of pieces of content, ranging from the most recent comedy shows to documentaries and vintage classics.
Amazon.com/mytv
Amazon.com/mytv.com
Amazon.co.uk/mytv
This approach allows the customer to personally explain their write my essay requirements or the additions that have arisen. You will be able to personally control the process of performing your work. To order an essay is very simple, you just need to go to our website and contact our managers or leave a request for a job.
Fubo tv is an American streaming television service that focuses on live sports such as the NFL, MLB, NBA, NHL, Major League Soccer, and international soccer. News, network television shows, and movies are also covered by the channel.
Fubo.tv/connect
It is a great blog post. I am Always reading your blog. Helpful and Informative blog. Thanks for sharing this information with us.
espn.com/activate
www.espn.com/activate
Hey...Great information thanks for sharing such a valuable information. We offering the best mcaffee activate services, you are just a click away https://mcaffee1act.com/
Check this blog and you will find how to access code in your smart tv
disneyplus.com/begin
At university, it was much harder to fix my scores, but then I found an https://writemypapers.company/edit-my-paper/ where all the writing is done perfectly, which makes me happy because now I take a break from studying more often
Lola Karpa is a 33-year-old former local activist who enjoys golf, travelling and praying. She is energetic and entertaining, but can also be very unstable and a bit disloyal. Now works as an author and editor at rapidessay.com
https://urbanmatter.com/best-mastercard-casino-online-in-canada/
An innovative IT firm delivering comprehensive technology solutions. We specialize in software development, network infrastructure, cloud computing, cybersecurity, and IT consulting.
Check out our website
PlambIndia
Post a Comment