开发者

Mass saving xls as csv

here's the trick. gotta convert 'bout 300 files from xls to csv, wrote some simple macro to do it, here's the code:

Dim wb As Workbook

For Each wb In Application.Workbooks
wb.Activate

    Rows("1:1").Select
    Selection.Delete Shift:=xlUp
    ActiveWorkbook.SaveAs Filename:= _
        "C:\samplepath\CBM Cennik " & ActiveWorkbook.Name & " 2010-04-02.csv" _
        , FileFormat:=xlCSV, CreateBackup:=False
Nex开发者_开发百科t wb

but it doesn't do exactly what i want - saves file "example.xls" as "example.xls 2010-04-02.csv", what i need is "example 2010-04-02.csv"

need support guys ;)


You could try to remove the extension in your filename.

Instead of ActiveWorkbook.Name use

Left(ActiveWorkbook.Name, InStrRev(ActiveWorkbook.Name, ".") - 1)

to remove everything after the last . in the filename (including the .).


A quick and dirty method is to

Replace(ActiveWorkbook.Name, ".xls", "")


local := true - took the values from the Control Panel Regional settings and therefore got that variable as a delimiter instead of the "," (comma). Fantastic

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜