Hi
I don't have a lot of knowlege in COM so the problem that I encountered was very strange to me.
I'm trying to create a button in my Word appliction through a Shard Addin project in C#.
When I'll press this button a certain logic that I wrote will be executed.
I encountered two problems.
1) I can't create the button in my Word application but only in my outlook and I don't know why.
I followed exactly the code that's written here:
http://support.microsoft.com/default.aspx scid=kb;en-us;302901
But the button was not created.
I Added the right assemblies for Word and Office and the CheckBox for "Register for COM interop" was checked.
I tried to install all of office components again but it still didn't worked
Then I tried to check whether the Addin workd at all so I wrote a messageBox in the OnStartupComplete to see if the MessageBox shows-up.
The MessageBox - MessageBox.Show("Hi") - only shows up in Power Point and Outlook. Not in Word or Excel.
2) After the button will be clicked I want to retrieve the path of the current Word Document that's running.
Since I couldn't do it with Word, I tried to do it with "Power Point" just to see that it works.
I created a string variable that holds the path of the current object according to the code that I found here in a similar question.
I checked to see if the file path was retrieved by setting one of the MessageBox parameters with the string value of the path:
Type CurrentApplicationType
= applicationObject.GetType(); object ActiveDocument = CurrentApplicationType.InvokeMember("ActivePresentation", System.Reflection.BindingFlags.GetProperty, null, applicationObject, null); ActiveFilePath = (string)ActiveDocument.GetType().InvokeMember("FullName", System.Reflection.BindingFlags.GetProperty,null, ActiveDocument, null); MessageBox.Show("ActiveFilePath", ActiveFilePath);
The result was that the MessageBox doesn't show up at all.
It does shoes up when I write a regular MessageBox - MessageBox.Show("Hi").