Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default CSV file has ,,,,,below last data row

I generate a csv file from Access , creating an Excel object. The csv is for
upload into an Oracle database. Using Notepad, I see rows and rows of
,,,,,,,,,,,,,,,, after the last data row. I thought adding a row count
parameter to CopyFromRecordset would help...

CopyFromRecordset rsCSVmst, rowCount, iCount

.... would cure the problem. It didn't. I then tweaked the line:

xlWbMst.SaveAs Filename:=fNameMst, FileFormat:=6

trying constants 20, 23. Still, didn't work. How do I eliminate those
empty rows of commas in my resulting CSV file?

The query from which the dao object is built has no blank rows.
Here's the code:
Dim xlWbMst As Object
Dim IStartedXL As Boolean
Dim i As Integer, iCount As Integer, rowCount As Long

IStartedXL = False
'PUT IF OBJECT NOT EXIST CREATE IT HERE?
On Error Resume Next
Set xlAppMst = GetObject(, "Excel.Application")
On Error GoTo 0
If xlAppMst Is Nothing Then
Set xlAppMst = CreateObject("Excel.Application")
IStartedXL = True
End If

Set xlWbMst = xlAppMst.Workbooks.Add

Dim rsCSVmst As DAO.Recordset
Set rsCSVmst = db.OpenRecordset("qtmpMasterCSV")
iCount = rsCSVmst.Fields.Count
rowCount = rsCSVmst.RecordCount

xlAppMst.Range("A1").Select
For i = 0 To iCount - 1
xlAppMst.Cells(1, i + 1).Value = rsCSVmst.Fields(i).Name
Next i
i = 0

xlAppMst.Range("A2").CopyFromRecordset rsCSVmst, rowCount, iCount
xlWbMst.SaveAs Filename:=fNameMst, FileFormat:=6
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
Open external data (varying file names) and closing file once data is retrieved Corrie Excel Programming 2 December 31st 06 09:56 PM
Capture data in one 'destination' file from varied 'source' file stored in one single folder. Smits Excel Programming 4 October 7th 06 12:35 PM
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM
How do I import text file, analyze data, export results, open next file Geoffro Excel Programming 2 March 6th 05 08:02 PM
Open delimited text file to excel without changing data in that file zohanc Excel Programming 1 October 3rd 03 01:06 AM


All times are GMT +1. The time now is 08:39 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"