I'm running Access 2007 and have a table with several Excel file attachments (one attachment per record). Each record has a Type field to identify the various files. In VBA, I'm running a routine to save the Excel file to my hard drive. Here is an excerpt from my code:
Everything has been working with this for several months. In fact, it worked yesterday. However, today, I'm getting a runtime error on the SaveToFile command. The error I'm getting is:
Error number: -2147024891
Error description: HRESULT: &H80070005
I have no idea what is going on and what is causing this error! I'm thinking this doesn't have anything to do with the Excel file itself, but must be something that changed in the environment.
Does anyone know what this error is and what could be causing it?
Code:
Set rs = db.OpenRecordset("SELECT * FROM tbl_Attachments WHERE [Type]='Header';")
If rs.NoMatch Then
MsgBox "The header file could not be found. Please contact the database administrator." & vbNewLine & _
vbNewLine & "Error occurred at: '" & strProc & ", " & strCodeLocn & "'.", vbCritical, "Critical Error"
GoTo Exit_Prepare_Accruals
End If
Set rsChild = rs.Fields("Attachment").Value
Set fldAttach = rsChild.Fields("FileData")
strFilePath = "c:\jeupload.xlsx"
If Len(Dir(strFilePath & "") & "") <> 0 Then
Kill strFilePath
End If
fldAttach.SaveToFile strFilePath
rsChild.Close
rs.Close
Everything has been working with this for several months. In fact, it worked yesterday. However, today, I'm getting a runtime error on the SaveToFile command. The error I'm getting is:
Error number: -2147024891
Error description: HRESULT: &H80070005
I have no idea what is going on and what is causing this error! I'm thinking this doesn't have anything to do with the Excel file itself, but must be something that changed in the environment.
Does anyone know what this error is and what could be causing it?