Quick explanation of the setup:
I have a custom taskpane loaded on startup as follows:
tpane is a UserControl that I've added a textbox to. So now when Word starts up with this add in, the taskpane will show up with the UserControl tpane and a textbox named tResult.
Now what I want to do is from within VBA call a function that will take the highlighted text on the word document and add it to this textbox. This is the function I have (working) in VBA that's calling upon the function in VSTO to perform this:
And now my only issue is, how do I reference the textbox "tresult"
I have a custom taskpane loaded on startup as follows:
C#:
tpane _ctrl = new tpane();
var myPane = this.CustomTaskPanes.Add(_ctrl, "My Control");
myPane.DockPosition = Microsoft.Office.Core.MsoCTPDockPosition.msoCTPDockPositionRight;
myPane.Visible = true;
myPane.Width = 400;
tpane is a UserControl that I've added a textbox to. So now when Word starts up with this add in, the taskpane will show up with the UserControl tpane and a textbox named tResult.
Now what I want to do is from within VBA call a function that will take the highlighted text on the word document and add it to this textbox. This is the function I have (working) in VBA that's calling upon the function in VSTO to perform this:
Visual Basic:
Sub CallVSTOMethod_addthetext()
Dim addIn As COMAddIn
Dim automationObject As Object
Set addIn = Application.COMAddIns("Test002")
Set automationObject = addIn.Object
Debug.Print automationObject.f_addthetext(Selection.Text)
End Sub
And now my only issue is, how do I reference the textbox "tresult"
C#:
public void f_addthetext(string seltext)
{
(This is the unknown for me here)
tResult.text = seltext;
}
Last edited by a moderator: