423,321 Members | 1,167 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,321 IT Pros & Developers. It's quick & easy.

MS Access VBA "Automation Error"

100+
P: 119
I have the following vba code that returns the "date modified" field from a file, specified in filepath:

Expand|Select|Wrap|Line Numbers
  1. Function GetFileModifiedDate(filepath As String) As Date
  2.  
  3.     Dim fs, f
  4.     Set fs = CreateObject("Scripting.FileSystemObject")
  5.     Set f = fs.GetFile(filepath)
  6.  
  7.     GetFileModifiedDate = f.datelastmodified
  8.  
  9. End Function
On one machine it runs without any problems, but on another I encounter the following error message:

Expand|Select|Wrap|Line Numbers
  1. Run-time error (8007007e) 
  2. Automation error 
  3. The specified module could not be found.
Does anyone know how to fix this?

Thanks,
May 19 '08 #1
Share this Question
Share on Google+
9 Replies


ADezii
Expert 5K+
P: 8,584
I have the following vba code that returns the "date modified" field from a file, specified in filepath:

Expand|Select|Wrap|Line Numbers
  1. Function GetFileModifiedDate(filepath As String) As Date
  2.  
  3.     Dim fs, f
  4.     Set fs = CreateObject("Scripting.FileSystemObject")
  5.     Set f = fs.GetFile(filepath)
  6.  
  7.     GetFileModifiedDate = f.datelastmodified
  8.  
  9. End Function
On one machine it runs without any problems, but on another I encounter the following error message:

Expand|Select|Wrap|Line Numbers
  1. Run-time error (8007007e) 
  2. Automation error 
  3. The specified module could not be found.
Does anyone know how to fix this?

Thanks,
  1. Set a Reference to the Microsoft Scripting Runtime Library.
  2. Rename your Function to:
    Expand|Select|Wrap|Line Numbers
    1. GetFileModifiedDate_2
  3. Modify the Function code to:
    Expand|Select|Wrap|Line Numbers
    1. Function GetFileModifiedDate_2(filepath As String) As Date
    2.  
    3. Dim fs As FileSystemObject
    4. Dim f As File
    5.  
    6. Set fs = CreateObject("Scripting.FileSystemObject")
    7. Set f = fs.GetFile(filepath)
    8.  
    9. GetFileModifiedDate_2 = f.DateLastModified
    10. End Function
  4. Let me know how you make out.
May 20 '08 #2

100+
P: 119
Thanks for your reply. I tried what you suggested but with no success. Given that the original code worked on one machine, but not the other. Would this not imply that the issue is with the machine, rather than the code?
May 20 '08 #3

ADezii
Expert 5K+
P: 8,584
Thanks for your reply. I tried what you suggested but with no success. Given that the original code worked on one machine, but not the other. Would this not imply that the issue is with the machine, rather than the code?
Given that the original code worked on one machine, but not the other. Would this not imply that the issue is with the machine, rather than the code?
It would appear that way. I was almost sure that 1 of the three suggestions would have solved the problem, but obviously not (LOL). I'll put my Thinking Cap on again and get back to you if I arrive at a solution.
May 20 '08 #4

NeoPa
Expert Mod 15k+
P: 30,996
When it said "The specified module could not be found.", were there any clues as to what the module referred to might be?
May 21 '08 #5

100+
P: 119
No, although it has to be associated with the code above...

I have spent a lot of time searching for a solution on the internet, and this is certainly not an isolated problem. Many people have had similar issues, with seemingly good code not working on one particular machine.

One such post is ** Link removed as per site rules **

Unfortunately, none of the forums I have visited have a posted solution!
May 21 '08 #6

NeoPa
Expert Mod 15k+
P: 30,996
Please remember not to link to other forum sites in your posts. I'm sure this was innocently done, but not allowed nevertheless.

As for Access error messages, although they can sometimes be helpful, they are also quite famous for being completely unrelated to the issue (as in - entirely spurious).

This can be particularly annoying when you find the solution which you only failed to find before because the error message actually indicated something completely different was at the root of the problem.
May 21 '08 #7

100+
P: 119
Okay, it seems that there was some kind of problem with scrun.dll.

I tried registering the dll again, using:

Expand|Select|Wrap|Line Numbers
  1. regsvr32 C:\WINDOWS\System32\Scrrun.dll
in the CMD prompt. It is now working...

Thanks for all your input.
May 21 '08 #8

NeoPa
Expert Mod 15k+
P: 30,996
Excellent :) Thanks for posting that.

Just for general usage it can also be used as :
Expand|Select|Wrap|Line Numbers
  1. regsvr32 %WinDir%\System32\Scrrun.dll
May 21 '08 #9

P: n/a
Hi billelev,
Thanks...
It really worked...
Oct 21 '10 #10

Post your reply

Sign in to post your reply or Sign up for a free account.