Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
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



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Xls to Csv -- remove formatting


Columns("A:Z").Select
Selection.NumberFormat = "@"

The code above does it (my spreadsheets never go past row Z)

Here was the problem, there were a couple columns formatted a
currency, so I was getting in the saved csv file:

xxxxx,"$3,001.45",xxxxxx

With that code above, it is now:

xxxxx,"3001.45",xxxxxx

No dollar signs or commas

It is working now!!

--
swtransactio
-----------------------------------------------------------------------
swtransaction's Profile: http://www.excelforum.com/member.php...fo&userid=3745
View this thread: http://www.excelforum.com/showthread.php?threadid=57121

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to remove all formatting Tom Excel Worksheet Functions 14 April 25th 10 08:50 AM
"Excel encountered an error and had to remove some formatting toavoid corrupting the workbook. Please re-check your formatting carefully." Greg Lovern Excel Discussion (Misc queries) 0 July 18th 08 09:42 PM
How to remove all formatting. Rick Wetzel Excel Discussion (Misc queries) 2 October 25th 06 02:31 AM
Remove all formatting ragtopcaddy Excel Worksheet Functions 3 February 28th 06 02:45 PM
Remove formatting from SSN Claire View New Users to Excel 3 October 9th 05 03:59 AM


All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"