Access VBA add Outlook attachment error

Posted on 2012-09-19
Last Modified: 2012-10-06
I have some VBA running behind a command button that when clicked takes some details from a query and sends an email containing this info, it also adds an attachment to the email.  The attachment is stored locally.  I cant see any reason why but this has now stopped working.  The error message i get is:

Run-time error'-2147024894 (80070002)2:
Cannot find this file.  Verify the path and file name are correct.

The error occurs on this line of code:

Set objOutlookAttach = .Attachments.Add("C:\test.doc")

Does anyone know why Access has suddenly stopped being able to find the file?
Question by:jdc1944
    LVL 19

    Assisted Solution

    by:Ken Butters
    Can I assume correctly that C:\test.doc exists?

    Are you running for first time on Windows 7 or Vista?  I'm wondering if this might be UAC (User Access Control) issue... where windows is preventing you from accessing the file at the root of the drive...

    you could try accessing the file from your documents folder or somewhere similar to see if that is really the issue.
    LVL 2

    Accepted Solution

    We're not using Windows 7 or Vista.  I've moved the file around, renamed it and now it is working again after moving back to C: and keeping its original name.  Cant really think what may have caused it.
    LVL 19

    Expert Comment

    by:Ken Butters
    Ok... glad it is working for you.
    LVL 2

    Author Closing Comment

    The issue resolved itself after renaming the file and moving the file around

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
    Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
    In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
    With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now