ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   opening text file as a .xls file and not a .xlsx (https://www.excelbanter.com/excel-programming/412251-opening-text-file-xls-file-not-xlsx.html)

Russ

opening text file as a .xls file and not a .xlsx
 
I am working in Excel 2007. In a file of type .xls I have recorded a macro
to open a text file as shown below:

Workbooks.OpenText Filename:="D:\MVCC\activity.dnl", Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1)),
TrailingMinusNumbers:=True

The code executes properly however the file that is opened is a .xlsx file
type. I would like the file type to be a .xls file type. Is there a way to
do this
--
russ

Ron de Bruin

opening text file as a .xls file and not a .xlsx
 
Hi Russ

Not test it but i think it use the format of the default save format
Office Button Excel Options Save

You can use code to open a xls workbook and use
ActiveSheet.QueryTables.Add to add the txt file if you not want to change the default
save format

If you need help post back


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Russ" wrote in message ...
I am working in Excel 2007. In a file of type .xls I have recorded a macro
to open a text file as shown below:

Workbooks.OpenText Filename:="D:\MVCC\activity.dnl", Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1)),
TrailingMinusNumbers:=True

The code executes properly however the file that is opened is a .xlsx file
type. I would like the file type to be a .xls file type. Is there a way to
do this
--
russ


Russ

opening text file as a .xls file and not a .xlsx
 
Hi Ron,
I had already tried your first suggestion and it did not solve the problem.
I like your second suggestion as it removes the step where I copy the
resulting sheet in the new file back to the workbook with the code. I had
not thought of this approach.
Thanks for you help
--
russ


"Ron de Bruin" wrote:

Hi Russ

Not test it but i think it use the format of the default save format
Office Button Excel Options Save

You can use code to open a xls workbook and use
ActiveSheet.QueryTables.Add to add the txt file if you not want to change the default
save format

If you need help post back


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Russ" wrote in message ...
I am working in Excel 2007. In a file of type .xls I have recorded a macro
to open a text file as shown below:

Workbooks.OpenText Filename:="D:\MVCC\activity.dnl", Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1)),
TrailingMinusNumbers:=True

The code executes properly however the file that is opened is a .xlsx file
type. I would like the file type to be a .xls file type. Is there a way to
do this
--
russ



Ron de Bruin

opening text file as a .xls file and not a .xlsx
 
See this page for code
http://www.rondebruin.nl/txtcsv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Russ" wrote in message ...
Hi Ron,
I had already tried your first suggestion and it did not solve the problem.
I like your second suggestion as it removes the step where I copy the
resulting sheet in the new file back to the workbook with the code. I had
not thought of this approach.
Thanks for you help
--
russ


"Ron de Bruin" wrote:

Hi Russ

Not test it but i think it use the format of the default save format
Office Button Excel Options Save

You can use code to open a xls workbook and use
ActiveSheet.QueryTables.Add to add the txt file if you not want to change the default
save format

If you need help post back


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Russ" wrote in message ...
I am working in Excel 2007. In a file of type .xls I have recorded a macro
to open a text file as shown below:

Workbooks.OpenText Filename:="D:\MVCC\activity.dnl", Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1)),
TrailingMinusNumbers:=True

The code executes properly however the file that is opened is a .xlsx file
type. I would like the file type to be a .xls file type. Is there a way to
do this
--
russ



Russ

opening text file as a .xls file and not a .xlsx
 
Hi Ron,
Thanks again. Your code is far superior to mine.
--
russ


"Ron de Bruin" wrote:

See this page for code
http://www.rondebruin.nl/txtcsv.htm

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Russ" wrote in message ...
Hi Ron,
I had already tried your first suggestion and it did not solve the problem.
I like your second suggestion as it removes the step where I copy the
resulting sheet in the new file back to the workbook with the code. I had
not thought of this approach.
Thanks for you help
--
russ


"Ron de Bruin" wrote:

Hi Russ

Not test it but i think it use the format of the default save format
Office Button Excel Options Save

You can use code to open a xls workbook and use
ActiveSheet.QueryTables.Add to add the txt file if you not want to change the default
save format

If you need help post back


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Russ" wrote in message ...
I am working in Excel 2007. In a file of type .xls I have recorded a macro
to open a text file as shown below:

Workbooks.OpenText Filename:="D:\MVCC\activity.dnl", Origin:=437, StartRow _
:=1, DataType:=xlDelimited, TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, Tab:=True, Semicolon:=False,
Comma:=False _
, Space:=False, Other:=False, FieldInfo:=Array(Array(1, 1), Array(2,
1), _
Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), Array(7, 1),
Array(8, 1), Array(9, 1), _
Array(10, 1), Array(11, 1), Array(12, 1), Array(13, 1)),
TrailingMinusNumbers:=True

The code executes properly however the file that is opened is a .xlsx file
type. I would like the file type to be a .xls file type. Is there a way to
do this
--
russ




All times are GMT +1. The time now is 03:07 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com