Return automation type from function

Debbie140Debbie140 Member Posts: 52
edited 2004-04-27 in Navision Attain
I have a function in a code unit that creates a word document. I want to return the word document object back to the calling function. Is this possible. I am using WordApp.ActiveDocument in the calling function at the moment to access the open word document but this does not always work. Is there a better way to get a handle on it.

Thanks
Debbie

Comments

  • wonmowonmo Member Posts: 139
    Create another automation variable of the Word, class Document:

    varDoc := WordApp.ActiveDocument;

    You can then access the methods and properties of the varDoc.
  • janpieterjanpieter Member Posts: 298
    1. Add an automation variable to your globals in the calling object.
    2. You don't have to use the CREATE code in the calling object.
    3. Create a function in the codeunit
    4. Give this function an parameter of the type Word.Document (didn't check, but should be something like this).
    5. Check the "VAR" option with this parameter.
    6. Use the parameter variable to create the document (and not the variable you already have in your CU, replace it.

    When you parse the variable made in step 1 to the function you will receive the created document in the calling object.

    (for examples of parsing automation variables to codeunits download the embedded controls demo and see how charts are filled by using standard codeunits, same principle)
    In a world without Borders or Fences, who needs Windows and Gates?
Sign In or Register to comment.