Official Content

Opens the specified document.  

Syntax

&VarBasedOnExtendedDataType.Open(FileName)

Where:

&VarBasedOnExtendedDataType
     Is a variable based on one of the following data types: ExcelDocumentWordDocumentFileXMLReaderXMLWriterWindow.

FileName
     Is the path and name of the document. If only the name is specified, the document will be created in the default directory (DataXXX model directory).

Type Returned:

  • For ExcelDocument and WordDocument data types, a Numeric type is returned. So, it is possible to call it as a function:
 &ErrorCode = &DataType.Open(…)
  •   When it is applied to the ExcelDocument data type, one of the following values is returned:
Value Result
0 OK 
4 Invalid template
10 Could not open file

               

  • When it is applied to the WordDocument data type, one of the following values is returned:
Value Result
0 OK 
6 Could not open file
10 Could not complete operation

            

  • For XMLWriter, XMLReader and File data types, no value is returned. So, for these data types the only way to know if the method has run successfully or not is by evaluating the ErrCode Property and the ErrDescription Property like the following code shows as a basic example:
if &File.ErrCode<>0 
   msg(&File.ErrDescription) //or other action
endif

These properties are valid for all the data types for which the Open method applies except for the Window data type.

  • For the Window data type, neither the method does not return a value nor the properties are valid.

Scope

Extended Data Types: ExcelDocumentWordDocumentFileXMLReaderXMLWriterWindow
Generators: .NET, Java, Ruby (up to GeneXus X Evolution 3), Visual FoxPro (up to GeneXus X Evolution 3)

Description

This method opens the path specified in the parameter (FileName). 

If the path corresponds to an Excel document or Word document:

  • If the specified document does not exist, it is created by using the template specified in the Template property.
  • When you open a document with the Open method, it is not displayed on the screen. To show it, you must use the Show method.
  • If you need to know if the spreadsheet already exists you can use file.exists().

See Also

Complete list of error Codes and Messages returned by all the methods for ExcelDocument data type
Complete list of error Codes and Messages returned by all the methods for WordDocument data type









Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant