Microsoft Office Tutorials and References
In Depth Information
17.1.6 OpenText Method
WorkbooksObject .Open( FileName , UpdateLinks , ReadOnly , _
Format , Password , WriteResPassword , IgnoreReadOnlyRecommended , _
Origin , Delimiter , Editable , Notify , Converter , AddToMRU )
Most of these parameters are rarely used (several of them relate to opening text files, for instance).
We discuss the most commonly used parameters and refer the reader to the help files for more
information. Note that all of the parameters are optional except FileName .
FileName is the file name of the workbook to be opened. To open the workbook in read-only
mode, set the ReadOnly parameter to True .
If a password is required to open the workbook, the Password parameter should be set to this
password. If a password is required but you do not specify the password, Excel will ask for it.
The AddToMru parameter should be set to True to add this workbook to the list of recently used
files. The default value is False .
17.1.6 OpenText Method
This method will load a text file as a new workbook. The method will parse the text data and place
it in a single worksheet. The rather complex syntax is:
WorkbooksObject .OpenText( Filename , Origin , StartRow , _
DataType , TextQualifier , ConsecutiveDelimiter , Tab , _
Semicolon , Comma , Space , Other , OtherChar , FieldInfo )
Note first that all of the parameters to this method are optional except the FileName parameter.
The Filename parameter specifies the filename of the text file to be opened.
The Origin parameter specifies the origin of the text file and can be one of the following
XlPlatform constants:
Enum XlPlatform
xlMacintosh = 1
xlWindows = 2
xlMSDOS = 3
End Enum
Note that the xlWindows value specifies an ANSI text file, whereas the xlMSDOS constant
specifies an ASCII file. If this argument is omitted, the current setting of the File Origin option in
the Text Import Wizard will be used.
The StartRow parameter specifies the row number at which to start parsing text from the text file.
The default value is 1.
The optional DataType parameter specifies the format of the text in the file and can be one of the
following XlTextParsingType constants:
Enum XlTextParsingType
xlDelimited = 1 ' Default
xlFixedWidth = 2
End Enum
Search JabSto ::

Custom Search