Some Problem when I switch to NETOffice

Apr 20, 2015 at 2:25 PM
Edited Apr 22, 2015 at 1:52 PM
I developed a word addin with MS VSTO. And recently, I try to switch these code into netoffice, and now I encounter some problem.

The first problem:
When I want to load a Word build-in dialog, there are two ways :
Both of them can load InsertCrossReference Dialog correctly, but there is a difference between them. The first one can load the Dialog as a non-modal form, and the second couldn't, even you write like this:


Usually, a user defined form could be load as a non-modal form with "show(0)", but in this problem, it doesn't work.

So, here is the problem when I transfer the VSTO code into netoffice.
I try the second method, and it works correctly as a modal form. But, I couldn't find a similar way
like the first method with netoffice.

The second problem:
When I load a user defined form (as a non modal form), I don't know how to link the form class with the current document operation. In the VSTO, I would define Application and Selection in form class as:
Dim Application As Word.Application = Globals.ThisAddIn.Application
Dim Selection As Word.Selection = Globals.ThisAddIn.Application.Selection
Since, there isn't "ThisAddin" in netoffice to present the word application, I define things like this:
Dim Application As NetOffice.WordApi.Application = Addin.Application
Dim Selection As NetOffice.WordApi.Selection = Addin.Application.Selection
When I debug this, there is no error, but it doesn't work.

I hope someone could help me to solve these problems.
Thanks again!
Apr 22, 2015 at 1:31 PM
please let me know its a NetOffice Tools Addin? in other words your addin class inherites from COMAddin ???
(if its a tool addin you can create your own singleton very easy with 5 code lines to imitate ThisAddin)

NetOffice spend a feature for VB developers to copy and paste VBA code as easy as possible.

its one line more in your import statements(Word example):
Imports NetOffice.WordApi.GlobalHelperModules.GlobalModule

Now you can use:

Dim x As Object = Application.Selection

"but in this problem, it doesn't work."

"it doesnt work "is not a good error description all the time ;) what happen in detail ?

Apr 22, 2015 at 1:52 PM

I change my code like this:
Imports NetOffice.WordApi
Dim Application As NetOffice.WordApi.Application = GlobalHelperModules.GlobalModule.AddIns.Application
Dim Selection As NetOffice.WordApi.Selection = GlobalHelperModules.GlobalModule.AddIns.Application.Selection
And everything works!

Do you have any idea about the dialog things? I really want the dialog as a non-modal form.
Is there a corresponding way of this method in word, as
to use building-in dialog.

Thanks again!
Apr 22, 2015 at 2:10 PM
i'm currently on my workplace but i want create a test at home.

what i see now ist the named argument problem.

NO doesnt support named arguments at the moment because some programming languages in .NET can't handle optional arguments(C# needs a couple of generations to learn this).

your call "id:=775" is a named argument call. (it means use the optional argument id and ignore all other optionals but NO doesnt have optional arguments at all. NO gives you all possible method overlads instead)

please try:

Application.CommandBars.FindControl(Nothing, 75).Execute() ' call in correct argument order


Apr 22, 2015 at 2:30 PM
I already try the way you told me, just like this:
 Application.CommandBars.FindControl(Nothing, 775).Execute()
And it works!!!

Thank you very much!

The next thing is to add the complicity with Word 2003 and deploy it.
Can you read my another post about the commandbar for 2003

It's very kind of you!