Exporting data to Excel
I am trying to export data from Access to Excel and then subsequently send the data via Outlook to particular users. Using the following code, I was able to get the data to export once, but can't seem to get it to export again. I receive the following error:
Run-time error 3422: Can't modify table structure. Another user has the table open.
Code:
Function ExporttoExcel()
'Open Excel Workbook, export the data, then close the wkbk.
Dim openWorkbook As Object, name As String
Set openWorkbook = Workbooks.Open("D:\Recertifications.xls")
DoCmd.TransferSpreadsheet acExport, _
SpreadsheetType:=acSpreadsheetTypeExcel9, _
TableName:="Recertifications", _
FileName:="D:\Recertifications.xls", _
HasFieldNames:=True
openWorkbook.Close
End Function
ANY help to get this working properly would be great!
THANKS.
|