Hirstmg

I'm new to VSTO and am using VSTO SE with Word2003. I am evaluating whether to convert a large application in VBA to VSTO for Word 2003. When I set up a Word Addin I have added a WinForm on which the user can select various things from databases (using code from other dotnet apps i have done). What I find i can't do is use that info in the VSTO class.

In more detail:

I have thisaddin.cs and form1.cs

thisaddin creates a new command bar with button with onClick action

Form1 frm = new Form1();
frm.Show();

so user opens word, clicks on the button and gets a new dotnet winform with a bunch of stuff on it. What i don't see is how to get the users selections on that form back into the thisaddin. I tried setting up a little procedure to call within thisaddin

public void WriteStuff(string textToWrite)
{this.Application.ActiveDocument.Application.Selection.TypeText(textToWrite);}

but when creating the reference in Form1 on button1_Click

it doesn't accept

VSTO1.ThisAddIn th = new VSTO1.ThisAddIn();
th.WriteStuff(tblName);

Error 1 No overload for method 'ThisAddIn' takes '0' arguments C:\vs\VSTO\VSTO1\VSTO1\Form1.cs 98 34 VSTO1

I guess the issue is i have created a diconnect between the addin and the form. is there a way of connecting them I note that if i were using Word 2007 I'd put the form stuff in a custom task pane thus binding it to Word but we can't do that in 2003.

Any suggestions

Thanks

Michael



Re: Visual Studio Tools for Office calling a winform and passing the info back to the addin

McLean Schofield - MSFT

If you need to call members of the ThisAddIn class from other classes in your project, use Globals.ThisAddIn (for example, you can call Globals.ThisAddIn.WriteStuff from your form class). The Globals class is a static class that is generated automatically in your project exactly for this purpose. For more information, see the http://msdn2.microsoft.com/en-us/library/bhczd18c(VS.80).aspx.

I hope this helps,

McLean Schofield






Re: Visual Studio Tools for Office calling a winform and passing the info back to the addin

Hirstmg

Thanks McLean
The Globals class is cool. It certainly works, and helps me get around the issue.
Many thanks
Michael