Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In Excel 2003, I am trying to take the contents of one sheet and save them as
a CSV. I have written the code below. When I walk through it in debug, it works fine. When I just run the macro, it get to the point of opening my copy and then goes off into space. Its like the newly opened workbook of seizing control from my macro. Sub Save_To_CSV() ' ' ExportDateRangeForDateLoad Macro ' Macro recorded 2/6/2008 by rolcott ' ' Keyboard Shortcut: Ctrl+Shift+K ' Dim channelNumber As Integer Dim XLFile, CSVFile, TermString As String Dim fs TermString = Mid(Worksheets("Instructions").Range("C20").Value, Len(Worksheets("Instructions").Range("C20").Value) , 1) If TermString < "\" Then Worksheets("Instructions").Range("C20").Value = Worksheets("Instructions").Range("C20").Value & "\" End If XLFile = Worksheets("Instructions").Range("C20").Value & "14_day_load_data.xls" CSVFile = Worksheets("Instructions").Range("C20").Value & "day_load_data.csv" ActiveWorkbook.SaveCopyAs (XLFile) Workbooks.Open Filename:=XLFile Workbooks("14_day_load_data.xls").Sheets("Generate d Dates").SaveAs Filename:=CSVFile, FileFormat:=xlCSV Workbooks("day_load_data.csv").Close Set fs = CreateObject("Scripting.FileSystemObject") fs.DeleteFile XLFile Sheets("Instructions").Select ' channelNumber = Application.DDEInitiate(app:="Cmd", topic:="/h") ' Application.DDEExecute channelNumber, "sqlldr st/st@docdw9 control=14_day_load.ctl errors=1000" ' Application.DDETerminate channelNumber End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Lost My Personal Macro Workbook | Excel Programming | |||
How do I find a lost macro? | Excel Discussion (Misc queries) | |||
How do I keep a running total of pounds lost and percentage lost | Excel Discussion (Misc queries) | |||
macro lost | Excel Discussion (Misc queries) | |||
lost password in a macro | Excel Programming |