S
swtransaction
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
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