How to use the FORMAT parameter in Workbooks.Open method?

1.9k Views Asked by At

The general syntax for the Workbooks.Open method in VB.net to open an excel file is: expression.Open (FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad).

The fourth parameter is the FORMAT which MSDN documentation says that is to be used when excel opens a text file. I tried opening a text file programmatically but got an error (which was expected). So can someone pls explain the use of the the FORMAT parameter in the syntax above? And is it something that is used frequently when we are programmatically opening excel files??

code used to open text file using excel:

oxl = CreateObject("Excel.Application")
oxl.Visible = True
oxl.Workbooks.Open("G:\Excel Experiments\Test.docx")
1

There are 1 best solutions below

0
Eugene Astafiev On

The Workbooks.Open method has the following description for the Format parameter:

If Microsoft Excel opens a text file, this argument specifies the delimiter character. If this argument is omitted, the current delimiter is used.

You can specify one of the following values in the Format parameter to determine the delimiter character for the file.

Value Delimiter
1 Tabs
2 Commas
3 Spaces
4 Semicolons
5 Nothing
6 Custom character (see the Delimiter argument)