PDA

Click to See Complete Forum and Search --> : Exporting Excel file items to a text file


gaby5
Jan 12th, 2004, 01:09 PM
Hello Friends,

I have a Excel file and i need to write a macro to export 1st column fields to a text file in which all the field elements are seperated by coma..could u pl suggest me how to do that, sample code will be helpful

Thanks

apps_tech
Jan 12th, 2004, 01:19 PM
I made a quick search in this forum. Here are two links that might help u:

http://www.vbforums.com/showthread.php?s=&threadid=85475&highlight=excel+file+export+text

http://www.vbforums.com/showthread.php?s=&threadid=266113&highlight=export+from+excel+to+text+file

gaby5
Jan 13th, 2004, 03:28 PM
Hello, this is not helping me, could u pl provide the code, what i need to do is copy certain range excel file and paste them in a text file seperated by comas, if i can write a macro that will be very helpful

Thanks

lintz
Jan 13th, 2004, 07:12 PM
Copy the range of data you want to save to a new sheet then use the below.
'Save as a text file
objExcel.ActiveWorkbook.SaveAs FileName:=C:\Test.txt, FileFormat:=xlText

gaby5
Jan 14th, 2004, 09:24 AM
Using this i am getting object failed error and i do not have help, could u give me the exact code please, thx

lintz
Jan 14th, 2004, 06:34 PM
This is to open the spreadsheet.

Dim oXLApp As Object
Dim objExcel As Object
Set objExcel = CreateObject("Excel.Application")
Set oXLApp = objExcel.Workbooks.Open(FileName:=C:\Book1.xls)
objExcel.Visible = False 'show excel or not
objExcel.DisplayAlerts = False
objExcel.WorkSheets("Sheet1").Select ' Select sheet to work with


and this is now to save as a txt file.


objExcel.ActiveWorkbook.SaveAs FileName:=C:\Test.txt, FileFormat:=xlText

HTH :)