Data Type For Word Documents Handling: Worddocument
Data Type For Word Documents Handling: Worddocument
Introduction
The objective of this new data type is to unify the interaction functions with the generation of Word documents for the different generated languages.
An important advantage of this implementation regarding the previous ones is that spread sheets are handled with an object oriented model and to
keep control of the Handles is not longer necessary.
Scope
Objects: Transactions, Work Panels, Web Panels, Procedures, Reports
Lenguages: Java, Visual Basic , Visual FoxPro
User Interface: Win
Description
The WordDocument data type was created to use this new feature. It allows for the generation of Microsoft Word documents, by means of its
properties and methods.
WordDocument
The properties and methods available for this data type are the following:
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 1/9
30/08/2019 Data type for word documents handling
PROPERTIES
ErrCode
Error code of the last operation.
Syntax: &WordDocument.ErrCode
ErrDescription
Error message of the last operation.
Syntax: &WordDocument.ErrDescription
ErrDisplay
It indicates whether error messages will be displayed or not.
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 2/9
30/08/2019 Data type for word documents handling
Syntax: &WordDocument.ErrDisplay
It specifies whether the message to be displayed to warn the user when an error occurs will include the text with the error (1) or not (0).
The default value is 0.
MacroReturnText
The last character type value returned by a call to a macro by means of the RunMacro method.
Syntax: &WordDocument.MacroReturnText
Note:
- This property is not available for the Java generator.
MacroReturnNumber
Last numeric value returned by a call to a macro by means of the RunMacro method.
Syntax: &WordDocument.MacroReturnNumber
Note:
- This property is not available for the Java generator.
MacroReturnDate
Las date type value returned by a call to a macro by means of the RunMacro method.
Syntax: &WordDocument.MacroReturnDate
Note:
- This property is not available for the Java generator.
ReadOnly
To open the next document as read only.
If ReadOnly is 1, the next calls to the Open method will cause the documents to be opened as read only. If it is 0, there will be an attempt to open the
documents as reading/writing, but if they are already opened they will be available as read only.
The default value is 0.
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 3/9
30/08/2019 Data type for word documents handling
Template
Name of the template to be used for new documents.
Syntax: &WordDocument.Template(Template)
It indicates the path and the name of the file which will be used as Template in the next calls to the Open method with a nonexistent file name.
The default value is the empty string. In this case, the default template will be used.
If there is a template defined, but then it is deleted because it is no longer needed, to use the default template again, a call to this property must be
made transferring an empty string as parameter (“”).
Text
Complete text of the document.
Syntax: &WordDocument.Text
In the event of wanting to add a new text to an existing document without losing the present format, the recommendation is to use the Append
method.
METHODS
Append
Syntax: &WordDocument.Append(Text)
Close
It saves the document and closes it.
Syntax: &WordDocument.Close()
Hide
It hides the document. If no document is visible, it hides the Word.
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 4/9
30/08/2019 Data type for word documents handling
Syntax: &WordDocument.Hide()
Open
It opens the specified document.
Syntax: &WordDocument.Open(FileName)
If the document specified in the parameter does not exist, it is created using the template specified in the Template property.
When opening a document by means of the Open method, it is not displayed on the screen. To show it, the Show method must be called.
The parameter may contain the path and the name of the document. If only the name is specified, the document will be created in the default
directory (DataXXX model directory).
Print
It prints the document in the default printer.
Note:
- In order to use this method you must set the preference “Functions” with the value “Allow non-standard functions on saving” in design and the
prototype/production “Functions” preference with the value “Allow non-standard functions on specifying”.
Replace
It allows to replace all the events of a text by another one.
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 5/9
30/08/2019 Data type for word documents handling
RunMacro
It runs the indicated Macro, contained in the document, with the specified parameters.
Notes:
· The parameters are only input parameters. If the called macro returns values, these will remain stored in the MacroReturnText,
MacroReturnNumber and MacroReturnDate properties, according to their types.
There is a maximum of 30 parameters. This is a Word limitation.
This function is not available for the Java generator.
· If this method is used with Office 97, it is not possible to use parameters. This is an Office 97 limitation. Thus, in this case, to invoke the
MacroReturnText, MacroReturnNumber and MacroReturnDate properties is not possible either.
Save
It saves the Word document on the disk.
Syntax: &WordDocument.Save()
SaveAs
It saves the document on a disk with a new name and, optionally, a new file type can be chosen.
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 6/9
30/08/2019 Data type for word documents handling
Show
It shows the document on the screen.
Syntax: &WordDocument.Show()
SpellCheck
It executes the spell check in the document.
Syntax: &WordDocument.SpellCheck()
Unbind
It allows to leave the Word document open after finishing the application.
Syntax: &WordDocument.Unbind()
This method is useful if you want to keep a document open after you have lost reach to the WordDocument object, even after the application is
finished.
When releasing a document, the reference between the WordDocument object and the open document is completely lost. Operations on the
WordDocument object do no longer affect the document. As a matter of fact, the WordDocument object behaves as if it does not have an open
document, until the Open method is called again.
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 7/9
30/08/2019 Data type for word documents handling
Code Message
0 Ok
2 Document no longer valid (it happens when a document
has been opened from a program and is manually closed
by the user).
3 Application no longer valid (it happens when Word is
manually closed by the user).
4 Invalid template
5 Invalid file name
6 Could not open file
7 Could not save file
8 Invalid value
9 Error running macro
10 Could not complete operation
General Conditions
- The above described methods were implemented in a specific way for them to return (as if they were functions) the error code. Thus, it is
possible to call them as functions.
I.E.:
&Err = &WordDocument.Open(File)
Examples
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 8/9
30/08/2019 Data type for word documents handling
library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 9/9