Share via

Opening Excel using VB from Access, getting runtime error 1004

Anonymous
2010-09-23T21:47:55+00:00

When I try to open an excel document from within access I receive the following error

Run-time error '1004'

Method 'OnKey' of object '_Application' failed

To open the excel document from within Access my code is

Call Shell("""C:\Program Files\Microsoft Office\Office14\Excel.EXE "" """ & strFname & """", 1)

and I have another one which is

Call ShellWait("""C:\Program Files\Microsoft Office\Office14\Excel.EXE "" """ & strFname & """", 3)

I have used both of these statements in Office 2003 for sometime and have never had a problem.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2010-09-24T00:40:42+00:00

    The other question I would have for you is are you able to execute such a command in the command prompt?  Or do you get an error there as well?

    Daniel Pineault

    http://www.cardaconsultants.com

    Free MS Access Tips and Code Samples: http://www.devhut.net

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-09-24T00:37:34+00:00

    You may want to take a look at:

    http://www.devhut.net/2010/06/12/ms-access-vba-open-a-file/

    and see if one of those methods don't do the trick for you.

    Daniel Pineault

    http://www.cardaconsultants.com

    Free MS Access Tips and Code Samples: http://www.devhut.net

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-09-23T22:46:12+00:00

    First thing I would check is your References...  You might have the wring Excel library checked.


    --

    Gina Whipp

    2010 Microsoft MVP (Access)

    Please post all replies to the forum where everyone can benefit.

    Was this answer helpful?

    0 comments No comments