Resolving TIA Portal Error 429 ActiveX CreateObject FileCtl

David Krause13 min read
SiemensTIA PortalTroubleshooting
Licensed PE Working through this on a live machine? A Maine-licensed engineer can take it from here — included with IMD hardware, by the hour for everything else. Book an engineer

Resolving TIA Portal VBScript Error 429: CreateObject("FileCtl.File") Fails on WinCE Comfort Panels

Error #429 - ActiveX component can't create object is one of the most frequently reported runtime faults when porting WinCC Flexible or TIA Portal VBScript projects to PC-based simulation. The error surfaces on the line Set fo = CreateObject("FileCtl.File"), immediately after the call to instantiate the FileCtl.File COM object. The fault is raised by the VBScript engine, not by the application code, which is why standard On Error Resume Next handlers still propagate it into ShowSystemAlarm as a system alarm on the HMI.

This article documents the exact root cause of the failure, the runtime/operating-system matrix that determines whether FileCtl.File is valid, and three production-ready workarounds: a dual-target script that detects WinCE versus Windows desktop, a native VBScript FileSystemObject implementation for WinCC Runtime Advanced / Professional on Windows, and a manual path quoting fix that resolves the closely-related secondary symptom of a malformed storage path.

Engineering note: Error 429 is generic. It does not only mean "FileCtl.File is missing." It is the COM layer returning CO_E_CLASSSTRING / REGDB_E_CLASSNOTREG because the requested ProgID is not registered in the host operating system. Always read Err.Description to confirm the class name before applying a fix.

1. Problem Details and Observable Symptoms

The failure pattern is consistent across TIA Portal V13 SP1 through V18:

  • Trigger: execution of any VBScript sub or function that calls CreateObject("FileCtl.File") from a button, scheduled task, or value-change event on an HMI tag.
  • Location: the runtime raises the error the moment CreateObject attempts to look up the ProgID in the host registry.
  • Visual: an alarm appears on the HMI with text such as Error # 429 ActiveX component can't create object. The same text is written to the WinCC RT log file ...\<project>\<runtime>\Logs\<date>_<time>.LOG when logging is enabled.
  • Affected projects: legacy WinCC Flexible 2008 SP3-5 projects migrated to TIA Portal, and new TIA Portal projects using the included sample "HMI Scripting - File Access" (entry ID 59604194 in the Siemens Industry Online Support) downloaded for testing.

The same code that fails in the PC simulator runs without error on the physical Comfort panel (KTP400, KTP700, KTP900, KTP1200, TP700, TP900, TP1200, TP1500, TP1900, TP2200) because the WinCE image on those devices ships with the FileCtl.File COM component pre-registered.

2. Root Cause: WinCE vs. Windows Runtime Incompatibility

The Siemens scripting help explicitly differentiates the supported object model by target platform. The relevant nodes are:

  • Visualize processes → Working with system functions and Runtime scripting → Reference → VB scripting → VBScript for Panels (Windows CE)
  • Visualize processes → Working with system functions and Runtime scripting → Reference → VB scripting → VBScript for WinCC Runtime Advanced
  • Visualize processes → Working with system functions and Runtime scripting → Reference → VB scripting → VBScript for WinCC Runtime Professional

Under VBScript for Panels (Windows CE) → CreateObject (Panels), the documentation lists FileCtl.File as the supported object for file I/O. The same ProgID is not listed under WinCC Runtime Advanced or WinCC Runtime Professional, because the desktop Windows runtime does not ship the FileCtl.File ActiveX server.

When TIA Portal starts the PC-based RT simulator, the VBScript engine runs inside the host operating system (Windows 7, Windows 10, or Windows 11) using the locally installed VBScript runtime (typically vbscript.dll version 5.812.x or 5.827.x from Windows Script Host). The FileCtl.File class is not registered in HKEY_CLASSES_ROOT\FileCtl.File on the host PC, so the COM activation call fails with HRESULT 0x80040154 (Class not registered) - the VBScript wrapper translates that into runtime error 429.

Microsoft knowledge base confirmation: Microsoft documents the same error 429 in the context of Office automation: "You receive run-time error 429 when you automate Office applications". Although that article targets Office COM servers, the underlying mechanism is identical - the COM server is either missing, unregistered, or running under a security context that does not permit in-process activation.

3. Affected Products, Firmware Versions, and TIA Portal Versions

Component Version / Article Number FileCtl.File Support
KTP400 Comfort 6AV2 124-1DC01-0AX0 (WinCE 6.0) Yes (registry pre-loaded)
KTP700 / KTP900 / KTP1200 Comfort 6AV2 124-... / 6AV2 125-... (WinCE 6.0) Yes
TP700 / TP900 / TP1200 Comfort 6AV2 124-... / 6AV2 125-... (WinCE 6.0) Yes
TP1500 / TP1900 / TP2200 Comfort 6AV2 124-6... / 6AV2 125-6... (WinCE 6.0) Yes
Comfort Panel V2 / Unified Comfort Panel WinCC Unified runtime No - VBScript not supported; use JavaScript / C#
WinCC Runtime Advanced (PC) 6AV2 104-... (TIA V13-V18) No
WinCC Runtime Professional (PC) 6AV2 105-... (TIA V13-V18) No
WinCC RT Simulator (TIA Portal) Internal to TIA Portal V13 SP1-V19 No (inherits host OS registry)

Siemens sample project entry ID 59604194 "HMI Scripting - File Access on Panels and RT" demonstrates the same FileCtl.File pattern and will raise 429 if executed inside the PC simulator instead of on a real Comfort panel.

4. Diagnostic Procedure

Before applying a fix, capture the actual error details. The minimal diagnostic routine is:

  1. Add a ShowSystemAlarm line after the CreateObject call to print Err.Number, Err.Description, and Err.Source.
  2. Open the WinCC RT log directory (right-click the runtime tray icon → Diagnostics → Open log folder on PC, or via Start Center → System → Logs on the panel).
  3. On the panel, verify the COM registration with the registry editor: HKEY_CLASSES_ROOT\FileCtl.File\CLSID should resolve to a GUID on WinCE devices and be absent on the PC.
  4. Confirm the target device in TIA Portal: Project tree → Devices → HMI → Device configuration → General → Panel type or Runtime → HMI device. A value of "PC System" with WinCC RT Advanced or RT Professional selected definitively means the script must be re-written for desktop VBScript.

5. Solution A - Detect Target and Branch Execution (Recommended for Migrated Projects)

The most defensive pattern is to check the host environment inside the VBScript and choose the appropriate object. The FileCtl.File object exposes the same methods (Open, LineInputString, LinePrint, EOF, LOF, Close) as a thin wrapper around the WinCE file system, so the script logic is identical once the object is constructed.

' ===========================================================
' Read_Data - dual-target (WinCE panel + Windows RT)
' Tested on TIA Portal V13 SP1 - V18, WinCC RT Advanced
' ===========================================================
Sub Read_Data()
    Dim fo, path, mode, delimiter, data, splitdata, isWinCE
    mode = 1  '1 = Input (read)

    ' --- Detect host operating system ---
    On Error Resume Next
    Set fo = CreateObject("FileCtl.File")
    If Err.Number = 0 Then
        isWinCE = True
        Err.Clear
    Else
        isWinCE = False
        Err.Clear
        Set fo = Nothing
        Set fo = CreateObject("Scripting.FileSystemObject")
    End If
    On Error Goto 0

    ' --- Build platform-specific path ---
    If isWinCE Then
        If SmartTags("bExtension") = 0 Then
            path = "\Storage Card SD\datafile.txt"
            delimiter = vbTab
        Else
            path = "\Storage Card SD\datafile.csv"
            delimiter = ";"
        End If
    Else
        'Windows PC runtime - use a writable project path
        path = "C:\Siemens\Automation\HMI\datafile.txt"
        delimiter = vbTab
    End If

    If isWinCE Then
        fo.Open path, mode
        If Err.Number <> 0 Then
            ShowSystemAlarm "Error # " & Err.Number & " " & Err.Description
            Err.Clear : Exit Sub
        End If
        While fo.EOF = False
            data = fo.LineInputString
        Wend
        fo.Close
    Else
        'FileSystemObject equivalent
        If Not fo.FileExists(path) Then
            ShowSystemAlarm "File not found: " & path
            Exit Sub
        End If
        Dim ts
        Set ts = fo.OpenTextFile(path, 1)  '1 = ForReading
        data = ts.ReadAll
        ts.Close
    End If

    data = Replace(data, vbTab & vbTab, delimiter)
    splitdata = Split(data, delimiter)
    SmartTags("szDate")      = splitdata(0)
    SmartTags("szString_1")  = splitdata(1)
    SmartTags("iValue_1")    = splitdata(2)
    SmartTags("iValue_2")    = splitdata(3)

    Set ts = Nothing
    Set fo = Nothing
    ShowSystemAlarm "Reading of data was successful!"
End Sub

The On Error Resume Next / Err.Clear sequence around the first CreateObject is intentional. A failed COM activation sets Err.Number = 429 on Win32, which the script uses as a signal to switch to the desktop path. Always re-arm the handler (On Error Goto 0) before resuming normal logic to prevent silent propagation of subsequent errors.

6. Solution B - Manual Path Quoting (Common Side-Issue)

A secondary, frequently-reported symptom of the same script is a Runtime error 5 - Invalid procedure call or argument on the fo.open path, mode line. This is caused by an unquoted backslash in the path literal:

'WRONG - VBScript interprets "\S" as an unrecognized escape sequence
path ="\Storage Card SD\datafile.csv"

'CORRECT - escape the leading backslash by doubling it
path ="\Storage Card SD\datafile.csv"

The same fix applies to any hard-coded path beginning with a backslash. On the WinCE panel the path is relative to the file system root; on the PC runtime, prepend an absolute C:\... root.

7. Solution C - Avoid the Problem Altogether with WinCC Logging Tags

If the goal is simply to persist process values to a CSV for trending, configure a Logging tag with a data log instead of a VBScript. The data log writes natively through the WinCC runtime and never touches FileCtl.File:

  1. Project tree → HMI tags → select tag → Properties → Logging → enable Acquisition cycle.
  2. Project tree → Logs → add data log → select storage path (\Storage Card SD\Logs\ on panel, C:\Siemens\Automation\HMI\Logs\ on PC).
  3. Project tree → Screens → add Control → Trend view bound to the data log.

The data log mechanism is documented in the TIA Portal help node Visualizing processes → Configuring logs → Data logs and works identically on WinCE panels and PC-based WinCC Runtime Advanced / Professional.

8. Solution D - Migrate to WinCC Unified (For New Projects)

For greenfield projects, the Comfort V2 / Unified Comfort Panel generation (MTP700, MTP1000, MTP1200, MTP1500, MTP1900, MTP2200) runs the WinCC Unified runtime. VBScript is not supported; use JavaScript or C# within a Script object. File I/O in Unified uses:

  • HMIRuntime.FileSystem for read/write to the panel file system.
  • Node.js fs module within server-side JavaScript.

Attempting to use VBScript CreateObject("FileCtl.File") on a Unified panel will not raise error 429 because the script type is not VBScript - it is a compile-time error reported by the Unified Engineering editor.

9. Verification Procedure

After applying a fix, perform the following four verifications:

  1. Compile check. In TIA Portal, click Compile → Software (rebuild all) on the HMI device. Any unresolved reference in the script will surface here.
  2. Simulator run. Start the RT simulator (right-click HMI device → Start simulation). Trigger the read and write scripts from a button. Confirm the system alarm Reading of data was successful! or Storage of data was successful!.
  3. Panel transfer. Compile to a .hmi operator panel file, transfer to the physical Comfort panel via ProSave or TIA Portal Online → HMI device maintenance → Download to device, and verify on the panel.
  4. Log inspection. Confirm that the generated file on the panel (\Storage Card SD\datafile.csv) and on the PC contains the expected delimiter-separated rows.
Field caveat: When the dual-target script is deployed to the PC simulator, the WinCE branch is not taken. The first call CreateObject("FileCtl.File") is expected to fail - that failure is the detection mechanism. Do not "fix" it by removing the first CreateObject call; doing so breaks detection.

10. Quick Reference: Runtime → File Object Mapping

Runtime Host OS ProgID to use Reference
Comfort Panel (WinCE 6.0) Windows Embedded Compact 6.0 FileCtl.File TIA Portal help → VBScript for Panels (Windows CE) → CreateObject (Panels)
WinCC RT Advanced (PC) Windows 7 / 10 / 11 Scripting.FileSystemObject MS Scripting Runtime library (scrrun.dll), preinstalled
WinCC RT Professional (PC) Windows Server 2016+ / Win 10/11 Scripting.FileSystemObject or Excel.Application for CSV export TIA Portal help → VBScript for WinCC Runtime Professional
WinCC Unified Comfort Panel Linux-based runtime Use HMIRuntime.FileSystem TIA Portal help → JavaScript runtime API
S7-1200 / S7-1500 display (if any) n/a No file scripting supported n/a

11. Related Error Codes and What They Mean

VBScript Err.Number Typical Cause Corrective Action
429 COM class not registered (FileCtl.File on PC, or missing scrrun.dll) Branch to native Scripting.FileSystemObject; or re-register via regsvr32 scrrun.dll
5 Invalid path or invalid argument to file open Escape leading backslash; verify path exists
52 Bad file name or number Confirm \Storage Card SD\ is mounted on the panel
53 File not found Pre-check with fo.FileExists or panel Start Center → System → Storage
70 Permission denied on the PC runtime Run WinCC RT as a user with write access to the path; or write to %LOCALAPPDATA%\Siemens\HmiRuntime\<project>\
76 Path not found Create the directory first or use a known-existing path

12. Best Practices for Cross-Target VBScript

  • Wrap every CreateObject call in On Error Resume Next / Err.Clear / On Error Goto 0 when the script must run on both WinCE and Windows targets.
  • Always call Set fo = Nothing at the end of every sub to release the COM reference and prevent file handle leaks.
  • On the panel, the storage root is \Storage Card SD\ for the SD card slot. The internal flash path is \Flash\. The USB stick path is \Storage Card USB\. All three require the leading doubled backslash in VBScript.
  • On the PC runtime, prefer SmartTags("ProjectPath") or a project tag bound to a configured storage path to avoid hard-coding drive letters that may differ between engineering and runtime machines.
  • Never use the deprecated FileCtl.File for new projects. Use the data log system wherever possible.

13. FAQ

Why does my VBScript work on the physical Comfort panel but fail with Error 429 in the TIA Portal simulator?

The simulator runs the VBScript engine inside the host Windows OS (Windows 7/10/11), which does not have the FileCtl.File COM class registered. The Comfort panel runs Windows CE 6.0, which ships with that class. Use a dual-target script that detects the environment (try CreateObject("FileCtl.File") first; if it raises 429, fall back to Scripting.FileSystemObject).

Is there any way to register FileCtl.File on a Windows PC so I can use the same script everywhere?

No. FileCtl.File is a Siemens-proprietary WinCE ActiveX that is part of the panel firmware image. It is not redistributable for Windows desktop. Attempting to copy a WinCE DLL to a PC and register it will fail because the COM activation contract and the file system semantics are different.

The official Siemens sample project (entry 59604194) also fails with Error 429 - is the sample broken?

No. That sample is intentionally written for the WinCE panel target. When you start the RT simulator on the PC instead of downloading to a real panel, you inherit the host Windows registry, which lacks FileCtl.File. Download the compiled .hmi file to a Comfort panel and the same code runs without error.

Can I use FileSystemObject directly on the Comfort panel?

No. WinCE panels do not ship with scrrun.dll (Microsoft Scripting Runtime), so CreateObject("Scripting.FileSystemObject") raises the same error 429 in the opposite direction. The FileCtl.File object is the only path on the panel.

How do I make my script work on both the panel and the WinCC RT Advanced simulator without rewriting it twice?

Use a detection block at the top of the sub: attempt CreateObject("FileCtl.File") inside On Error Resume Next; if Err.Number = 429, set a flag and instantiate Scripting.FileSystemObject instead. Branch the rest of the file-open / read / write logic on that flag. The complete pattern is shown in section 5 of this article.

What is the right fix for the related error "Invalid procedure call or argument" on the file open line?

It is almost always a path-quoting issue. A leading backslash in a VBScript string literal must be doubled ("\Storage Card SD\file.txt"), otherwise the parser treats \S as an unsupported escape sequence. See section 6 of this article.

Does this also apply to WinCC Professional (TIA) on the PC?

Yes. WinCC Runtime Professional runs the VBScript engine under Windows, so FileCtl.File is not available. Use Scripting.FileSystemObject for plain-text file I/O, or the documented HMIRuntime tags for project-internal logging. Detailed object lists are in the TIA Portal help node "VBScript for WinCC Runtime Professional".

Back to blog