Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do i open excel file and save as csv in VB

Status
Not open for further replies.

Itopa

IS-IT--Management
Mar 24, 2002
7
0
0
NG
I want to open an excel file and then save as csv. Pls how do i using vb 6
 
Honestly I don't know how to connect to Excel through VB6 but I figured that this may help you if you can get round to using VBA within Excel.

ThisWorkBook.SaveAs FileFormat:=xlCSV, Filename:="C:\MyBook.CSV"

Maybe there is a way to do the same thing from within VB6.

Hope it helps,





yosherrs.gif

[tt]'Very funny, Scotty... Now Beam down my clothes.'[/tt]
 
'declare excel app object
Dim exl As New Excel.Application
'open the file
exl.Workbooks.Open "c:\somefile path..."
'save csv
exl.Workbooks(1).SaveAs "c:\newfile path...", xlCSV
'close
exl.Workbooks(1).Close False
'quit excel
exl.Quit
'clear
set exl = nothing

-Max
 
If you just whant to change the file type and not open the file you could use the name as method:
Code:
Name SomeFilePath\Excel.xls AS SomeFilePath\Excel.CSV

Everybody body is somebodys Nutter.
 
Renaming a .XLS file as a .CSV file will just create a mess! There have been several discussions on Excel & VB (see Search tab above) but you could start with faq222-3383

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top