Using wordbasic in X# / VO application

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
jonhn
Posts: 86
Joined: Thu Feb 01, 2018 8:04 am
Location: New Zealand

Using wordbasic in X# / VO application

Post by jonhn »

Hello again,
In my VO app I have used Wordbasic to generate some simple reports for the user in a new Word doc.

I would like to provide the same functionality in my X# application when converted, but can't figure out how to include the Wordbasic library in my project, and then reference it.

I found some docs from MS regarding C#, but 2 days trying to figure this out is making me crazy.
https://docs.microsoft.com/en-us/dotnet ... erty-value

Can anyone please list the steps involved in getting Wordbasic into the X# app and using it?
Maybe there is a better / different way...

In VO I declare it in the window class where I want it: PROTECT oWord AS wordbasic
And then simple stuff in the method.
SELF:oWord:=Wordbasic{}
IF !SELF:oWord:fInit
WarningBox{SELF,"Can't start MS-Word!","If Word is installed on this computer try opening it manually and try again."}:show()
RETURN NIL
ENDIF

SELF:oWord:FileNewDefault()
SELF:oWord:AppShow()

...<etc...>

Thanks!
Jonathan
User avatar
wriedmann
Posts: 3757
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

Using wordbasic in X# / VO application

Post by wriedmann »

Hi Jonathan,
the MS documentation says there is an assembly Microsoft.Office.Interop.Word.dll - you need to include that and add a "using Microsoft.Office.Interop.Word" on the top of your prg file.
I have that DLL file here (Office 2010):
c:WindowsassemblyGAC_MSILMicrosoft.Office.Interop.Word14.0.0.0__71e9bce111e9429cMicrosoft.Office.Interop.Word.dll
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Using wordbasic in X# / VO application

Post by robert »

Jonathan,

- Add a reference to the MsWord type library (see our example that covers Excel : https://www.xsharp.eu/help/example-4-ol ... ation.html )
- add a using statement for word: USING Microsoft.Office.Interop.Word
- create an object of the word application: oWord :=ApplicationClass{}
- don't use oWord:Finit, that is what we did with OleAutomation. If word can't be started you will get a normal .Net exception

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
jonhn
Posts: 86
Joined: Thu Feb 01, 2018 8:04 am
Location: New Zealand

Using wordbasic in X# / VO application

Post by jonhn »

Thank you Robert and Wolfgang, very helpful! I have found the other MS dll files that can also be referenced so will try to build those in too!

One more question, if I may:
I have a lot of errors: XS0102: The type 'XXXXXX' already contains a definition for 'XYZ'
BUT, I have only declared these variables in the one place.

What is it I need to find / fix to cure this error?
User avatar
robert
Posts: 4529
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Using wordbasic in X# / VO application

Post by robert »

Jonathan,
Jonathan Neil wrote: One more question, if I may:
I have a lot of errors: XS0102: The type 'XXXXXX' already contains a definition for 'XYZ'
BUT, I have only declared these variables in the one place.

What is it I need to find / fix to cure this error?
Give us more info ?

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
jonhn
Posts: 86
Joined: Thu Feb 01, 2018 8:04 am
Location: New Zealand

Using wordbasic in X# / VO application

Post by jonhn »

sorry.
In VO I have declared the variables in the class as INSTANCE or PROTECT, or they are Access/Assign variables.
Not all variables.

Looking at it right now, it looks like in X#, because several classes have been gathered up into .prg files, if each class had an instance of that variable, it was not a problem in VO, but in X# they are visible to each other... I need to go and check if that is the reason.
Thanks again.
User avatar
Chris
Posts: 4922
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Using wordbasic in X# / VO application

Post by Chris »

Hi Jonathan,

Please install the newest X# build (from today!), including the new XIDE and then re-export your code with the new VOXporter, it should take care of this as well (it will remove the INSTANCE variables)
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Post Reply