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

When VBA throws Run-time error 429: ActiveX component can’t create object on a line calling CreateObject("Scripting.FileSystemObject"), it means the Windows COM subsystem cannot locate, initialize, or execute the Microsoft Scripting Runtime component. This error occurs because Excel is running on macOS (which does not support ActiveX/COM), the underlying system DLL is unregistered or corrupted, system permissions are blocking the script host, or 32-bit and 64-bit registration entries have drifted after an Office update.

Quick Fix

If you are running Excel on Windows, verify your syntax and re-register the scripting runtime DLL by first closing Excel completely, opening an elevated Command Prompt (Windows Key > search cmd > right-click and select Run as administrator), running the command regsvr32.exe scrrun.dll, confirming the DllRegisterServer in scrrun.dll succeeded message appears, and then reopening your workbook to run the macro.

Step-by-Step Diagnostic Path

If the quick fix does not resolve the error, use the following progressive troubleshooting steps to identify the root cause.

                  [Run-time Error 429]
                           │
             Is Excel running on macOS?
              ├── YES ──► Use Dir/MacScript/AppleScript
              └── NO
                   │
         Does "regsvr32 scrrun.dll" succeed?
              ├── NO  ──► Check system integrity (SFC)
              └── YES
                   │
        Does Late Binding fail despite registration?
              ├── YES ──► Test Early Binding (Reference Check)
              └── NO  ──► Verify Bit-level registration

1. Verify the Operating System (macOS vs. Windows)

The Scripting.FileSystemObject (FSO) object model is a Windows-only ActiveX component compiled inside scrrun.dll. It does not exist in macOS versions of Excel.

  • Symptom: The error triggers instantly on macOS when executing Set fso = CreateObject("Scripting.FileSystemObject").
  • Action: Replace FSO-based calls with native VBA file handling methods such as Dir(), Get, Put, Open, FileCopy, and Kill, or branch execution based on the operating system:

VBA

#If Mac Then
    ' Use native VBA or AppleScript on Mac
    Dim folderPath As String
    folderPath = Dir(Environ("HOME") & "/*", vbDirectory)
#Else
    ' Windows COM implementation
    Dim fso As Object
    Set fso = CreateObject("Scripting.FileSystemObject")
#End If

For Mac-specific cross-platform automation and environment-specific file access, see Troubleshooting Mac vs. Windows VBA compatibility (ActiveX vs. AppleScript).

2. Resolve Bit-Architecture and Registry Discrepancies

On 64-bit editions of Windows, 32-bit and 64-bit COM objects live in separate registry hives and system directories. If you run 32-bit Office on 64-bit Windows (or vice versa), registration can point to the incorrect system path.

  • For 64-bit Office on 64-bit Windows or 32-bit Office on 32-bit Windows, register the 64-bit / standard system file:
    regsvr32.exe C:\Windows\System32\scrrun.dll
  • For 32-bit Office on 64-bit Windows, explicitly register the 32-bit runtime file:
    C:\Windows\SysWOW64\regsvr32.exe C:\Windows\SysWOW64\scrrun.dll

If regsvr32 returns error code 0x80070005 (Access Denied), ensure your command prompt was opened with administrative privileges. If it returns 0x80004005 or file not found, the DLL is missing from your system directory.

3. Test Early Binding vs. Late Binding

Switching from late binding (CreateObject) to early binding (referencing the library directly) helps isolate whether the failure stems from dynamic COM object creation or a missing/broken type library.

  1. Open the VBA Editor (Alt + F11).
  2. Click Tools > References.
  3. Scroll down and check Microsoft Scripting Runtime.
  4. Click OK.
  5. Update your code declaration:

VBA

Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject

Hidden Conditions & Next Steps

If re-registering scrrun.dll and checking library references fail to resolve Error 429, check these underlying system conflicts:

  • Corrupted System Binaries: Run sfc /scannow in an administrative Command Prompt to repair damaged Windows core files.
  • Security Software and Group Policy Restrictions: Enterprise Endpoint Detection and Response (EDR) software or Group Policies targeting Windows Script Host (WSH) can block scrrun.dll execution inside Microsoft Office applications. If the issue affects multiple users across an organization, confirm with IT whether COM activation for script runtimes has been restricted.
  • General ActiveX Subsystem Failures: If other objects (like WScript.Shell or ADODB.Connection) also fail with Error 429, the root issue is broader than FileSystemObject. See Runtime Error 429: ActiveX component can’t create object (Broken DLLs) for complete COM subsystem repair steps.