Question : Export Query to Excel from Access 2007

Hi, I am exporting a query result to Microsoft Excel file using the vba code showed below. I am creating this file in excel in order I can import the transactions to JD Edwards. For some reason, when JD Edwards validates the file it detects that there are blank lines after the last record in Excel.  I need a vba code that I can integrate in the code below that automatically delete all lines in blank after the last record. I thought we could use the first column of the worksheet for detecting if it is blank, then that will be the trigger for deleting the whole line, but I dont know how to do it. Please help.



Function ExportFile()
Dim strFilename As String
strFilename = "C:\KRISPY_IMPORT_EXPORT\salesimport.xls"
DoCmd.TransferSpreadsheet TransferType:=acExport, SpreadsheetType:=acSpreadsheetTypeExcel8, TableName:="GlManualEntries", FileName:=strFilename

Dim excel As Object
Dim book As Object
Dim sheet As Object
Set excel = CreateObject("Excel.Application")
excel.DisplayAlerts = False
Set book = excel.workbooks.Open(strFilename)
Set sheet = book.worksheets(1)
sheet.Columns(8).Formula = sheet.Columns(8).Formula
sheet.Columns(9).NumberFormat = "#,##0.00"
sheet.Columns(10).NumberFormat = "#,##0.00"
book.Save
excel.Quit
End Function

Answer : Export Query to Excel from Access 2007

While it could be something different, this problem on one of the systems I fixed was due to the disk controller reverting from DMA to PIO mode.  The fix was to go into device manager and remove the "primary ide channel" and the "secondary ide channel" and then reboot.  Windows should auto-detect the hardware again and reset it correctly.

See screen shot attached.
Random Solutions  
 
programming4us programming4us