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
0
Comments
varDoc := WordApp.ActiveDocument;
You can then access the methods and properties of the varDoc.
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)