Handling “ActiveX can’t create object” when using FileSystemObject.

The alert Runtime Error 429: ActiveX component can't create object appears when a VBA procedure attempts to instantiate the FileSystemObject via CreateObject("Scripting.FileSystemObject") or New FileSystemObject, but the Windows operating system fails to register, locate, or authorize the Microsoft Scripting Runtime library.

Quick Answer

If running on Windows, re-register the scripting engine by opening Command Prompt as Administrator and running regsvr32.exe scrrun.dll. If the error occurs on macOS, rewrite the code using native VBA file functions (Dir, Open, FileCopy), because ActiveX and the Scripting Runtime do not exist on Unix operating systems.


Why the Error Occurs

The FileSystemObject (FSO) is part of the Microsoft Scripting Runtime library (scrrun.dll). It is not an internal component of the VBA language; it is an external COM (Component Object Model) server provided by Windows.

When your code executes:

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")

Excel queries the Windows Registry (HKEY_CLASSES_ROOT\Scripting.FileSystemObject\CLSID) to locate the dynamic link library responsible for the object. Error 429 occurs if:

  1. The workbook is executing on a platform that does not support COM (macOS).
  2. The registration for scrrun.dll is missing, damaged, or unmapped in the Windows Registry.
  3. System security software, Application Whitelisting (AppLocker), or Group Policy blocks the Windows Script Host from instantiating COM objects.
  4. An early-bound reference in the VBA project points to a missing or version-mismatched type library.

Step-by-Step Diagnostic Path

Follow this structured diagnosis to identify the source of the breakdown:

                    Runtime Error 429 on FileSystemObject
                                      │
                         Is the machine running macOS?
                                     ╱ ╲
                               YES  ╱   ╲  NO
                                   ╱     ╲
                  ActiveX is unsupported   Is the code using Early Binding
                  on Mac. Use native VBA   or Late Binding?
                  file statements.          ╱ ╲
                                Early Binding ╲ Late Binding
                                     ╱         ╲
                   Check Tools > References:   Re-register scrrun.dll via
                   Is MS Scripting Runtime     Admin Command Prompt;
                   missing or broken?          check security software.

Step 1: Verify the Operating System

ActiveX is a proprietary Windows technology. Excel for Mac does not include the COM subsystem, meaning any call to CreateObject("Scripting.FileSystemObject") fails on macOS immediately.

  • The Resolution: If your workbook must support Mac users, replace FSO methods with native cross-platform VBA commands:
    • Replace fso.FileExists(path) with Len(Dir(path)) > 0
    • Replace fso.DeleteFile(path) with Kill path
    • Replace fso.CreateFolder(path) with MkDir path
    • Replace fso.CopyFile(src, dest) with FileCopy src, dest

For details on managing mixed environments safely, see Troubleshooting Mac vs. Windows VBA compatibility (ActiveX vs. AppleScript).

Step 2: Re-Register the Scripting Library in Windows

If the error occurs on Windows, the COM registration mapping for scrrun.dll is likely damaged.

  1. Close Excel completely.
  2. Click the Windows Start menu, type cmd, right-click Command Prompt, and select Run as administrator.
  3. For standard 64-bit Windows installations running 64-bit Office (or 32-bit Windows): regsvr32.exe %windir%\system32\scrrun.dll
  4. For 64-bit Windows running 32-bit Office: regsvr32.exe %windir%\syswow64\scrrun.dll
  5. Press Enter. You should see a confirmation dialog: “DllRegisterServer in scrrun.dll succeeded.”
  6. Re-open Excel and run the macro.

If you encounter general COM registration failures across multiple automation libraries, see Runtime Error 429: ActiveX component can’t create object (Broken DLLs).

Step 3: Repair Missing Early-Bound References

If your code uses early binding (Dim fso As New FileSystemObject or Dim fso As Scripting.FileSystemObject), the VBA project depends on an explicit reference set in the project properties. If that reference becomes unmapped, compilation fails with Error 429 or “User-defined type not defined”: Missing library references (Tools > References).

  • The Fix:
    1. Open the VBA Editor (Alt + F11).
    2. Click Tools > References.
    3. Scroll through the selected items at the top of the list. Look for any item marked MISSING: Microsoft Scripting Runtime.
    4. If marked missing, uncheck it, scroll down, check the valid Microsoft Scripting Runtime entry pointing to scrrun.dll, and click OK.
    5. Alternatively, switch to late binding to eliminate project reference dependencies entirely: Dim fso As Object Set fso = CreateObject("Scripting.FileSystemObject")

Step 4: Verify Group Policy and Script Host Restrictions

In locked-down corporate IT environments, administrators may disable the Windows Script Host (WSH) through registry keys to prevent script-based attacks.

  • The Diagnostic Check:
    1. Check the Windows Registry key:
      HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Script Host\Settings
    2. If a DWORD value named Enabled is present and set to 0, COM object instantiation for scripting libraries is blocked globally.
    3. If your company restricts scripting runtimes via Group Policy, you cannot use Scripting.FileSystemObject. You must refactor your macro to use native VBA file-handling statements.

If the file you are attempting to interact with via FSO is stored in a synchronized cloud folder, ensure the path itself is formatted correctly by reviewing Fixing VBA errors caused by “OneDrive” autosave and temp file paths.