LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Macro gets lost

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
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
Lost My Personal Macro Workbook SteveM Excel Programming 3 November 26th 07 03:27 PM
How do I find a lost macro? Jan Excel Discussion (Misc queries) 2 July 23rd 07 08:42 PM
How do I keep a running total of pounds lost and percentage lost angel5959 Excel Discussion (Misc queries) 4 January 26th 06 09:18 PM
macro lost Pam Coleman Excel Discussion (Misc queries) 1 February 24th 05 08:27 PM
lost password in a macro Planetnieuws Excel Programming 2 July 25th 03 10:50 AM


All times are GMT +1. The time now is 07:15 AM.

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

About Us

"It's about Microsoft Excel"