M
Medes
Hi all,
I have three questions i hope you can help me.
1. why my add-ins dont work for ms word? i use same code with changes (app
...) and it works for excel. (actualy it works for ms word too but i dont know
what i have changed, now ms word dont answer to any add-ins).
2. how can i get custom perpeties for the active document, I want to add
text as new custom property for active document by clikcing on a button.
2. why my code does not insert text to active cell in excel. here is a litle
bit of code that should insert text to active cell it locate in Connect.cs
Excel.Application excelApp = null;
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
excelApp = (Excel.Application)application;
insertText = MakeANewButton(toolBar, "Insert text", 1044, new
_CommandBarButtonEvents_ClickEventHandler(insertText_Click));
}
private CommandBarButton MakeANewButton(CommandBar commandBar, string
caption, int faceID, _CommandBarButtonEvents_ClickEventHandler clickHandler)
{
object missing = System.Reflection.Missing.Value;
try
{
Microsoft.Office.Core.CommandBarButton newButton;
newButton =
(CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton,
missing, missing, missing, missing);
newButton.Caption = caption;
newButton.FaceId = faceID;
newButton.Click += clickHandler;
return newButton;
}
catch
{
return null;
}
}
public void insertText_Click(CommandBarButton barButton, ref bool someBool)
{
if (excelApp != null)
{
this.excelApp.ActiveCell.Value2 = "someText";
}
}
I have three questions i hope you can help me.
1. why my add-ins dont work for ms word? i use same code with changes (app
...) and it works for excel. (actualy it works for ms word too but i dont know
what i have changed, now ms word dont answer to any add-ins).
2. how can i get custom perpeties for the active document, I want to add
text as new custom property for active document by clikcing on a button.
2. why my code does not insert text to active cell in excel. here is a litle
bit of code that should insert text to active cell it locate in Connect.cs
Excel.Application excelApp = null;
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
excelApp = (Excel.Application)application;
insertText = MakeANewButton(toolBar, "Insert text", 1044, new
_CommandBarButtonEvents_ClickEventHandler(insertText_Click));
}
private CommandBarButton MakeANewButton(CommandBar commandBar, string
caption, int faceID, _CommandBarButtonEvents_ClickEventHandler clickHandler)
{
object missing = System.Reflection.Missing.Value;
try
{
Microsoft.Office.Core.CommandBarButton newButton;
newButton =
(CommandBarButton)commandBar.Controls.Add(MsoControlType.msoControlButton,
missing, missing, missing, missing);
newButton.Caption = caption;
newButton.FaceId = faceID;
newButton.Click += clickHandler;
return newButton;
}
catch
{
return null;
}
}
public void insertText_Click(CommandBarButton barButton, ref bool someBool)
{
if (excelApp != null)
{
this.excelApp.ActiveCell.Value2 = "someText";
}
}