Converting file formats

R

Ryan Brown

I'm programing in visual basic.net and I need to convert
a excel spred sheet file into a text file(tab delimited)
and back again. Does anyone know how I could do this. I
assume there is a class that will make it easy but I
can't seem to find it. Thanks.
 
I

Izar Arcturus

If you have room/time to save the file during the macro
you could do it like this:

Private Sub ToTextNBackAgain()
ActiveWorkbook.SaveAs Filename:= _
"C:\ExcelFileAtStart.txt", FileFormat:= _
xlText, CreateBackup:=False
'at this point the file has been converted to text
ActiveWorkbook.SaveAs Filename:= _
"C:\ExcelFileAtStart.xls", FileFormat:= _
xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
'at this point the file has been converted back to an Excel
End Sub

-IA
 
P

Pyball

Ryan,

When you are in Visual Studio .Net open your project then goto
Project>Add Reference. Then click on the COM tab. Scroll do to
Microsoft Excel (version number) Object Library and click on it to
highlight it. Then click on the Select button. Then click the Ok
button.

The Excel object module will now be available to you in Visual
Studio. You should be able to now manipulate Excel from Visual Basic.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top