If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
cannot delete spreadsheet cells for an export
I keep getting this message saying "cannot delete spreadsheet cells" but i
don't know why?? can anyone help me please?? my code below Sub exportspreadsheet() On Error GoTo HandleError Dim objXLApp As Object Set objXLApp = CreateObject("Excel.Application") Dim objXLBook As Excel.Workbook Dim db As DAO.Database Set db = CurrentDb conPath = GetPath(db.Name) 'delete the spreadsheet Kill conPath & "temp_MonthlySalesReport" ' create a workbook from the template Set objXLApp = New Excel.Application Set objXLBook = objXLApp.Workbooks.Open(conPath & "temp_MonthlySalesReport.xlt") 'objXLApp.Visible = True objXLBook.SaveAs (conPath & "temp_MonthlySalesReport.xlsm") objXLBook.Close DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "temp_MonthlySalesReport", "F:\Accounts\Projects\Analysis\Billlings\DSICMM\Ac cess\temp_MonthlySalesReport", True, "temp_MonthlySalesReport" MsgBox "Done!" & vbCrLf & vbCrLf & "Look in the directory" & vbCrLf & vbCrLf & "where the application sits for ""temp_MonthlySalesReport.xls""" ProcDone: On Error Resume Next ' Let's clean up our act Set qdf = Nothing Set db = Nothing Set rs = Nothing Set objResultsSheet = Nothing Set objXLBook = Nothing Set objXLApp = Nothing ExitHe Exit Sub HandleError: Select Case Err.Number Case 3265 Resume Next Case 1004 Set objXLBook = objXLApp.Workbooks.Open(conPath & "temp_MonthlySalesReport") Resume Next Case 53 Resume Next Case 75 Resume Next Case Else MsgBox Err.Description, vbExclamation, _ "Error " & Err.Number End Select Resume ProcDone End Sub |
#2
|
|||
|
|||
cannot delete spreadsheet cells for an export
You are running your front-end on the server, and it appears the spreadsheet
as well. If anyone is connected to the spreadsheet file, you cannot delete it. You wouldn't know that because your error handler just tells the process to continue anyway. First, before you corrupt your database, split it and put the front-end on your workstation. Then comment out the error handlers and see what the errors are. Typically, someone opens the file and just leaves it running. If you move the Excel file locally too, you can avoid that problem. -- Arvin Meyer, MCP, MVP http://www.datastrat.com http://www.accessmvp.com http://www.mvps.org/access "Alan" wrote in message ... I keep getting this message saying "cannot delete spreadsheet cells" but i don't know why?? can anyone help me please?? my code below Sub exportspreadsheet() On Error GoTo HandleError Dim objXLApp As Object Set objXLApp = CreateObject("Excel.Application") Dim objXLBook As Excel.Workbook Dim db As DAO.Database Set db = CurrentDb conPath = GetPath(db.Name) 'delete the spreadsheet Kill conPath & "temp_MonthlySalesReport" ' create a workbook from the template Set objXLApp = New Excel.Application Set objXLBook = objXLApp.Workbooks.Open(conPath & "temp_MonthlySalesReport.xlt") 'objXLApp.Visible = True objXLBook.SaveAs (conPath & "temp_MonthlySalesReport.xlsm") objXLBook.Close DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "temp_MonthlySalesReport", "F:\Accounts\Projects\Analysis\Billlings\DSICMM\Ac cess\temp_MonthlySalesReport", True, "temp_MonthlySalesReport" MsgBox "Done!" & vbCrLf & vbCrLf & "Look in the directory" & vbCrLf & vbCrLf & "where the application sits for ""temp_MonthlySalesReport.xls""" ProcDone: On Error Resume Next ' Let's clean up our act Set qdf = Nothing Set db = Nothing Set rs = Nothing Set objResultsSheet = Nothing Set objXLBook = Nothing Set objXLApp = Nothing ExitHe Exit Sub HandleError: Select Case Err.Number Case 3265 Resume Next Case 1004 Set objXLBook = objXLApp.Workbooks.Open(conPath & "temp_MonthlySalesReport") Resume Next Case 53 Resume Next Case 75 Resume Next Case Else MsgBox Err.Description, vbExclamation, _ "Error " & Err.Number End Select Resume ProcDone End Sub |
Thread Tools | |
Display Modes | |
|
|