Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    New York
    Posts
    45

    Unanswered: xls to csv using bat file

    Hello,
    I want to gather a small portion of an Excel spreadsheet and write the data to a comma delimited file for import into another program with SQLLdr + I need to delete a first row...

    So far, I have a bat. file that grab an xls file from one directory , copy that file to another as csv format..

    But I can not find a way to remove a first row in already formated file.

    I was trying to use this in my bat file but it did not worked the way I want it. /p250 /1 2-150 by
    It just opend a file for me to delete...

    Suggestions?

    Thanky you.

    A.

  2. #2
    Join Date
    Apr 2004
    Location
    Bothell, WA
    Posts
    4

    why not build a macro

    I'm no whiz at batch files, but what you're trying to do sounds like it should be easy to do as a macro. If you want it to be configurable, or save the file in a specific location you could do that in the VBA code, but if you just want to grab the same set of cells, delete the top row and save it as a csv file then try this code (you can modify the file location to fit your needs):

    Sub csvsaver()

    Rows("1:1").Select
    Application.CutCopyMode = False
    Selection.Delete Shift:=xlUp
    ChDir "C:\Documents and Settings\Default\Desktop"
    ActiveWorkbook.SaveAs Filename:= _
    "C:\Documents and Settings\Default\Desktop\Book1.csv", FileFormat:=xlCSV, _
    CreateBackup:=False

    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •