Access VBA add Outlook attachment error

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?
LVL 2
jdc1944Asked:
Who is Participating?
 
jdc1944Author Commented:
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.
0
 
Ken ButtersCommented:
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.
0
 
Ken ButtersCommented:
Ok... glad it is working for you.
0
 
jdc1944Author Commented:
The issue resolved itself after renaming the file and moving the file around
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.