0% found this document useful (0 votes)
83 views

Data Type For Word Documents Handling: Worddocument

This document discusses a new data type called WordDocument that allows for the generation and handling of Microsoft Word documents from different programming languages. The WordDocument data type has properties like ErrCode, ErrDescription, and ReadOnly that provide information about the document. It also has methods like Append, Open, Print, and Replace that allow manipulating the document by adding or replacing text, opening and saving files, and printing. The goal of this data type is to provide a unified way to interact with Word documents across multiple languages.

Uploaded by

cigano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
83 views

Data Type For Word Documents Handling: Worddocument

This document discusses a new data type called WordDocument that allows for the generation and handling of Microsoft Word documents from different programming languages. The WordDocument data type has properties like ErrCode, ErrDescription, and ReadOnly that provide information about the document. It also has methods like Append, Open, Print, and Replace that allow manipulating the document by adding or replacing text, opening and saving files, and printing. The goal of this data type is to provide a unified way to interact with Word documents across multiple languages.

Uploaded by

cigano
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

30/08/2019 Data type for word documents handling

DATA TYPE FOR WORD DOCUMENTS HANDLING

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:

Property Type Access


ErrCode Numeric Reading
ErrDescription Character Reading
ErrDisplay Numeric Reading/Writing
MacroReturnText Character Reading
MacroReturnNumber Numeric Reading
MacroReturnDate Date Reading
ReadOnly Numeric Reading/Writing
Template Character Reading/Writing
Text Character Reading/Writing

Method Parameters Type

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

Append Text Character


Close (none)
Hide (none)
Open FileName Character
Print Preview Numeric
Background Numeric
Replace OldText Character
NewText Character
MatchCase Numeric
MatchWholeWord Numeric
RunMacro MacroName Character
Par1 … Par30 (Any one)
Save (none)
SaveAs FileName Character
FileType Character
DOSText Numeric
LineBreaks Numeric
Show (none)
SpellCheck (none)
Unbind (none)

PROPERTIES

ErrCode
Error code of the last operation.

Syntax: &WordDocument.ErrCode

See the “Error Codes and Messges” section in this document.

ErrDescription
Error message of the last operation.

Syntax: &WordDocument.ErrDescription

See the “Error Codes and Messges” section in this document.

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.

Syntax: &WordDocument.ReadOnly = Valor

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

It adds a new text at the end of a document.

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.

Syntax: &WordDocument.Print([Preview[, Background]])

Preview Numeric It indicates whether the document will be displayed on the


screen, before printing it, or not. The possible values are 1
(the document is displayed) and 0 (the document is not
displayed).
This parameter is optional and the default value is 0.
Background Numeric It indicates whether there will be background printing (1)
or not (0). If the background printing is indicated, the
control will be returned to the caller program while the
printing is made and if the document is closed in the
program when the printing is not completed, the printing
will be cancelled. This parameter is optional and the
default value is 1.

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.

Syntax: &WordDocument.Replace(OldText, NewText[, MatchCase[, MatchWholeWord]])

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

OldText Character It indicates what is the text to be replaced.


NewText Character It indicates what the next text of the document will
be.
MatchCase Numeric If the value is 1, only the events with equal capital
and small letter configuration will be replaced. If the
value is 0 all the events will be replaced.
This parameter is optional and the default behavior is
as if the value were 0.
MatchWholeWord Numeric If the value is 1, only the events which are not part
of another word will be replaced. If the value is 0, all
the event will be replaced.
This parameter is optional and the default behavior is
as if the value were 0.

RunMacro
It runs the indicated Macro, contained in the document, with the specified parameters.

Syntax: &WordDocument.RunMacro(MacroName[, Par1 ... [,Par30]])

MacroName Character Macro to be run.


Par1 ... Par30 (Any one) Parameters used by the macro.

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.

Syntax: &WordDocument.SaveAs(FileName[, FileType[, DOSText[, LineBreaks]]])

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

FileName Character New name of the Word document.


FileType Character New file type to be generated from the Word document.
Valid file types are:
DOC (Word format)
RTF (Rich Text Format)
HTM (HyperText Markup/ HyperText Markup
Language)
DOT (DOC Template)
TXT (Texto)
This parameter is optional. The default file type is DOC.
DOSText Character If TXT type is specified, it can be specified whether the
format of the text to be used will be DOS (1) or not (0).
This parameter is optional. The default value is 0.
LineBreaks Numeric If TXT type is specified, it indicates whether a line break will
be added at the end of each line (1) or not (2).
This parameter is optional. The default value is 0.

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

Error Codes and Messages


The possible values are the following:

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)

Compatibility with previous Genexus versions


The Gxoffice functions, which existed until GeneXus 7.0 version, are still supported. The generator works in a way that it maps these functions
internally for them to use these new data types.
These functions are only supported by compatibility; thus, it is not recommended to make new implementations with them since the new features will
not be implemented in these functions.

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

This sample shows you how to use this new feature:


http://www.gxopen.com.uy/hproject.asp?126

library.gxtechnical.com/gxdl/pub/GeneXus/DevEnv/Docum/ReleaseNotes/7.5/WordDocument.htm#_Replace 9/9

You might also like