LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Creating properly formatted text file from vbscript using excel data

I have an excel spreadsheet named test.xls with A1:B2 populated this way:

A B
~ ~
1 2
3 4

What I want to do from VBScript is copy that data and export it to a tab
deliminated text file.

For example, I can create a document called hello.txt and in it, it would
have
1 2
3 4


I just started playing around with this and have the following so far:
'================================
Dim Xl
Dim myData

myData=""

Set Xl = CreateObject("Excel.Application")
Xl.Workbooks.Open("C:\test.xls")
Xl.Sheets("Sheet1").Select

for each r in Xl.Range("A1","B2")
myData = myData & r.value & vbTab
next

msgbox myData

Set Xl = Nothing
'================================

I haven't created the text file yet (that's trivial). The problem is that
the output comes as follows:

1 2 3 4




 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Line Chart from office 2003.xls not formatted properly in 2007 tj Excel Discussion (Misc queries) 0 December 9th 09 10:31 PM
CSV file doesn't save "xEy" style number as text formatted data [email protected] Excel Discussion (Misc queries) 1 July 30th 08 06:03 PM
Converting formatted text into a txt file Marc Excel Discussion (Misc queries) 1 June 21st 07 04:00 PM
Reading in poorly formatted text file Some Dude Excel Discussion (Misc queries) 1 February 11th 07 10:24 PM
Need help with creating a text file via excel [email protected] Excel Worksheet Functions 3 June 13th 05 02:49 PM


All times are GMT +1. The time now is 08:50 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"