Welcome, Guest
Username: Password: Remember me
Visual Objects

Please use this forum to post questions about Visual Objects and Vulcan.NET
  • Page:
  • 1

TOPIC:

Using wordbasic in X# / VO application 16 Oct 2019 07:40 #11207

  • jonhn
  • jonhn's Avatar
  • Topic Author


  • Posts: 84
  • 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.
    docs.microsoft.com/en-us/dotnet/api/micr...d-pia#property-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

    Please Log in or Create an account to join the conversation.

    Last edit: by jonhn.

    Using wordbasic in X# / VO application 16 Oct 2019 08:36 #11209

    • wriedmann
    • wriedmann's Avatar


  • Posts: 3366
  • 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:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\14.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll
    Wolfgang
    Wolfgang Riedmann
    Meran, South Tyrol, Italy

    www.riedmann.it - docs.xsharp.it

    Please Log in or Create an account to join the conversation.

    Using wordbasic in X# / VO application 16 Oct 2019 08:38 #11210

    • robert
    • robert's Avatar


  • Posts: 3595
  • Jonathan,

    - Add a reference to the MsWord type library (see our example that covers Excel : www.xsharp.eu/help/example-4-ole-automation.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

    Please Log in or Create an account to join the conversation.

    Using wordbasic in X# / VO application 16 Oct 2019 11:19 #11214

    • jonhn
    • jonhn's Avatar
    • Topic Author


  • Posts: 84
  • 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?

    Please Log in or Create an account to join the conversation.

    Using wordbasic in X# / VO application 16 Oct 2019 11:20 #11215

    • robert
    • robert's Avatar


  • Posts: 3595
  • 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

    Please Log in or Create an account to join the conversation.

    Using wordbasic in X# / VO application 16 Oct 2019 11:44 #11216

    • jonhn
    • jonhn's Avatar
    • Topic Author


  • Posts: 84
  • 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.

    Please Log in or Create an account to join the conversation.

    Using wordbasic in X# / VO application 16 Oct 2019 17:16 #11221

    • Chris
    • Chris's Avatar


  • Posts: 3980
  • 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)
    XSharp Development Team
    chris(at)xsharp.eu

    Please Log in or Create an account to join the conversation.

    • Page:
    • 1