简体   繁体   中英

Excel VBA CreateObject: Run-time error '432': File name or class not found during Automation operation

How do I fix the error "Run-time error '432': File name or class not found during Automation operation" I get when calling "CreateObject("Scripting.FileSystemObject")" in Excel VBA?

I have a spreadsheet with a macro that works on two other computers and used to work on my computer before I factory restored it and reinstalled Office.

I am on Windows 7 64-bit, running Office Home and Student 2010.

I traced the error down and created a new spreadsheet with a macro that runs a single line:

Set objFSO = CreateObject("Scripting.FileSystemObject")

This macro runs fine on 2 other computers, so there's something in my PC environment that's screwing me up. I get the error:

Run-time error '432': File name or class name not found during Automation operation

I've tried repairing the Office installation and completely uninstalling and reinstalling Office.

From what I can find on the internet, I might need a reference to "Microsoft Scripting Runtime". I believe this is the file scrrun.dll. When I go to add this reference to my project, it shows me that the location of "Microsoft Scripting Runtime" is "C:\\Users\\\\Documents". You can see this in the attached image full of errors. That doesn't seem like the correct location, and there are no dlls there.

If I check that reference to include it and hit OK, I get the error:

Error in loading DLL

scrrun.dll is found in "C:\\Windows\\System32" I tried registering the dll and it worked fine. Unregistering gives me the error:

The module "scrrun.dll was loaded but the call to DLLUnregisterServer failed with error code 0x800300002.

I made sure the Administrators group owns that file in case it was a permissions issue. I also tried unregistering while running in Safe Mode.

I may be off on a total tangent looking at the "Microsoft Scripting Runtime" reference and/or scrrun.dll.

Thanks for any advice!

各种错误的屏幕截图

It works with me as below. Hope it helps - I find scrrun.dll in C:\\Windows\\SysWOW64. I register it in this location successfully - Recheck in VBA Reference, it shows location of Microsoft Scripting Runtime as C:\\Windows\\SysWOW64\\scrrun.dll

Then i have no below error anymore "Run-time error '432': File name or class not found during Automation operation" I get when calling "CreateObject("Scripting.FileSystemObject")" in Excel VBA"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM