Thanks Thanks:  0
Likes Likes:  0
Results 1 to 2 of 2

Thread: SaveToFile Runtime Error -2147024891

  1. #1
    Board Regular
    Join Date
    May 2008
    Posts
    54
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default SaveToFile Runtime Error -2147024891

    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:

    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?

  2. #2
    Board Regular
    Join Date
    May 2008
    Posts
    54
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: SaveToFile Runtime Error -2147024891

    I figured out my issue! I realized that I started having this problem after my company upgraded my machine from Windows XP to Windows 7. After looking into changes with this upgrade, I learned that I no longer have permissions to save to the C:\ root directory. I just changed my code to save to another location and voila -- the code now works as it did before!

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •