View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
NickHK NickHK is offline
external usenet poster
 
Posts: 4,391
Default Xls to Csv -- remove formatting

Not sure why .SaveAs csv does not achieve your aim.
What are you trying to achieve ?

NickHK

"swtransaction"
wrote in message
news:swtransaction.2ci1rh_1155507619.4927@excelfor um-nospam.com...

I'm using this to convert XLS to CSv files in batch. The XLS files are
formatted and it would help a lot if they were not.

Can I automate removing the format? Thanks !!!!


Private Sub cmdXlsCsv_Click()

On Error GoTo MyError

Screen.MousePointer = vbHourglass

Dim xls As Excel.Application
Dim oWB As Excel.Workbook
Dim tmp As String
Set xls = New Excel.Application
tmp = Dir("C:\cmo\*.xls")
Do While tmp ""
Set oWB = xls.Workbooks.Open("C:\cmo\" & tmp)
'clear formatting here
oWB.SaveAs FileName:=Replace _
("C:\cmo\" & tmp, ".xls", ".csv", , , vbTextCompare), _
FileFormat:=xlCSVMSDOS, CreateBackup:=False
oWB.Close SaveChanges:=False
tmp = Dir
Set oWB = Nothing
Loop
xls.Quit
Set xls = Nothing

Screen.MousePointer = vbDefault

MyError:

If Err.Number = 1004 Then
MsgBox "Csv File Exists", vbOKOnly + vbExclamation
xls.Quit
Set xls = Nothing
Screen.MousePointer = vbDefault
End If
tabManage.SetFocus
End Sub


--
swtransaction
------------------------------------------------------------------------
swtransaction's Profile:

http://www.excelforum.com/member.php...o&userid=37459
View this thread: http://www.excelforum.com/showthread...hreadid=571210