A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Access » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

cannot delete spreadsheet cells for an export



 
 
Thread Tools Display Modes
  #1  
Old April 29th, 2010, 09:57 AM posted to microsoft.public.access
Alan
external usenet poster
 
Posts: 459
Default 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  
Old April 29th, 2010, 02:25 PM posted to microsoft.public.access
Arvin Meyer [MVP][_2_]
external usenet poster
 
Posts: 2,310
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:37 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.