Exporting Data to Excel from Siemens HMI Panels via WinCC

David Krause13 min read
HMI ProgrammingSiemensTroubleshooting
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

Exporting Data to Excel from Siemens HMI Panels via WinCC flexible

Problem Overview: CreateObject("Excel.Application") Fails on Panels

Engineers deploying WinCC flexible 2005 SP1 HF7 on Siemens Comfort and Mobile Panels (TP270 10" Touch, MP277 10" Touch, TP1500 Comfort) frequently encounter a runtime failure when attempting to instantiate Excel through VBScript. The symptom is a script halt at the line:

Set objExcel = CreateObject("Excel.Application")

with a reported Error Number 429 and Error Description "ActiveX component can't create object". The identical script runs without fault on a PC Runtime station because that host has the full Microsoft Office COM layer registered; the WinCE / Windows Embedded-based panel firmware does not.

Critical constraint: Siemens Comfort, Mobile, and Multi Panel families ship with Windows CE 6.0 / Windows Embedded Standard 2009 / WinCC Runtime images. None of these images include Microsoft Excel, the Office PIA, or the Excel COM Type Library. Any VBScript path that depends on Excel.Application, Excel.Sheet, Excel.Workbook, or the Office Open XML SDK will terminate with HRESULT 0x800A01AD (decimal 429).

This article documents the architectural reason for the failure, the diagnostic flow to confirm it, and the canonical workarounds used in production deployments: writing CSV files through the panel's own file-system object, pushing them to a network share, and converting them on a host with Excel installed.

Affected Products and Firmware Versions

Panel Family Model Runtime OS WinCC flexible Version Excel COM Available?
170 / 270 series TP270 6", TP270 10" Touch/Key Windows CE 3.0 / 5.0 WinCC flexible 2004 – 2008 SP3 No
Mobile Panel 277 MP277 8" / 10" Touch/Key Windows CE 5.0 / 6.0 WinCC flexible 2005 SP1 HF7 – 2008 SP3 No
Comfort Panel TP1500 Comfort, TP1900 Comfort Windows Embedded Standard 7 WinCC flexible 2008 SP3, TIA Portal WinCC Comfort/Advanced V11+ No
PC Runtime WinCC Runtime Advanced (PC) Windows 7 / 10 / 11 WinCC flexible 2008 SP3, TIA Portal V13+ Yes (if Office installed)
WinCC Professional RT PC station with WinCC V7 Windows Server 2016+ WinCC V7.4+ Yes (if Office installed)

The Excel COM dependency is satisfied only when the runtime host is a full Windows installation with Microsoft Office registered. Panels of the TP and MP families listed above are intentionally locked-down embedded images; they cannot be extended with Excel or Office runtime libraries.

Root Cause Analysis: Why HRESULT 0x800A01AD

The VBScript runtime on a WinCC flexible panel resolves COM ProgIDs by querying the Windows registry under HKCR\CLSID\{00024500-0000-0000-C000-000000000046} for the Excel.Application class and the Office type libraries. On a panel, that CLSID is absent because the Office redistributables were never packaged into the firmware image.

The error mapping is:

Error.Number Hexadecimal Constant Meaning
429 0x800A01AD CTL_E_ACTIVEXERR ActiveX component can't create object
70 0x800A0046 PERMISSION_DENIED Permission denied (share access)
52 0x800A0034 BAD_FILE_OR_PATH Bad file name or number
53 0x800A0035 FILE_NOT_FOUND File not found
76 0x800A004C PATH_NOT_FOUND Path not found
61 0x800A003D DISK_FULL Disk full

When a developer copies a PC-side script that worked in a WinCC flexible PC Runtime (where Office is installed) to a panel target, the same line produces 429 because the COM server cannot be loaded. There is no WinCC flexible project setting, hotfix, or scripting option that can add Excel to the panel image.

Diagnostic Procedure: Confirming the Failure Mode

Before changing the architecture, confirm the error on the panel and capture it programmatically. The pattern below wraps the offending call in an error trap and writes the diagnostic output to a panel-local file so you can pull it via ProSave or Sm@rtService.

  1. Open the WinCC flexible project, navigate to Schedules > Tasks or attach the script to a button event.
  2. Replace the failing CreateObject call with the error-trapped variant.
  3. Transfer the project to the panel and trigger the button.
  4. Read the diagnostic file using ProSave > File Browser or Sm@rtService / Sm@rtAccess via \panel_ip\Storage Card\Log\diag.txt.
Sub DiagnosticExcel(sFileName)
  Dim objFSO, objLog
  On Error Resume Next
  Set objFSO = CreateObject("FileCtl.FileSystem")
  If Err.Number <> 0 Then
    MsgBox "FileCtl missing: " & Err.Number & " " & Err.Description
    Exit Sub
  End If
  Set objLog = objFSO.OpenTextFile(sFileName, 8, True)
  objLog.WriteLine "[" & Now & "] Trying Excel.Application..."
  Dim objExcel
  Set objExcel = CreateObject("Excel.Application")
  objLog.WriteLine "[" & Now & "] Err.Number=" & Err.Number & _
                   " Err.Description=" & Err.Description
  objLog.Close
  Set objFSO = Nothing
  Set objExcel = Nothing
End Sub

Expected output on a TP270 / MP277 / TP1500:

[2025-01-15 14:22:01] Trying Excel.Application...
[2025-01-15 14:22:01] Err.Number=429 Err.Description=ActiveX component can't create object

If FileCtl.FileSystem is also unavailable on legacy WinCE 5.0 panels, fall back to the FileSystemObject (the Scripting Runtime) which is registered by the WinCC flexible runtime on every supported panel firmware version since 2004.

Solution 1: CSV Export via FileSystemObject

The production-proven approach is to write a CSV file on a network share using FileSystemObject (or FileCtl.FileSystem on WinCE 5.0) and let a downstream Windows host convert it to XLSX. Excel opens CSV directly, and Office 365 / Excel 2016+ auto-applies delimiter detection on .csv files.

VBScript Template

Sub ExportToCSV(sUncPath, sFileName)
  Dim objFSO, objFile, objExcel ' NOTE: objExcel only used on PC RT
  Dim sLine, sPath
  Dim iRow, iCol
  
  sPath = sUncPath & "\" & sFileName & ".csv"
  
  On Error Resume Next
  Set objFSO = CreateObject("FileSystemObject")
  If Err.Number <> 0 Then
    Set objFSO = CreateObject("FileCtl.FileSystem")
    Err.Clear
  End If
  If Err.Number <> 0 Then
    MsgBox "No file system object: " & Err.Description
    Exit Sub
  End If
  
  ' Ensure target directory exists
  If Not objFSO.FolderExists(sUncPath) Then
    MsgBox "Share path not reachable: " & sUncPath
    Exit Sub
  End If
  
  Set objFile = objFSO.CreateTextFile(sPath, True, False) ' Unicode=False for ASCII CSV
  If Err.Number <> 0 Then
    MsgBox "CreateTextFile failed: " & Err.Number & " " & Err.Description
    Exit Sub
  End If
  
  ' Optional header row (use Tab delimiter for Excel friendliness)
  objFile.WriteLine "Timestamp;Tag1;Tag2;Tag3;Recipe"
  
  ' Iterate your internal tag array / archive
  For iRow = 0 To 999
    sLine = Now & ";" & _
           SmartTags("Data_Tag1")(iRow) & ";" & _
           SmartTags("Data_Tag2")(iRow) & ";" & _
           SmartTags("Data_Tag3")(iRow) & ";" & _
           SmartTags("Data_RecipeName")
    objFile.WriteLine sLine
  Next
  objFile.Close
  Set objFile = Nothing
  Set objFSO = Nothing
  
  MsgBox "Export complete: " & sPath
End Sub

CSV Encoding and Delimiter Notes

Delimiter Excel Locale Behavior Recommended Use
Comma (,) Default in EN-US; imported as thousands separator in DE-DE Only for EN-US deployments
Semicolon (;) Default in DE-DE and most EU locales Recommended for European plants
Tab (vbTab) Always imported as a single column boundary Recommended when locale varies

For Excel that auto-formats numeric columns, prepend an apostrophe to numeric strings to force text rendering:

objFile.WriteLine "'" & CStr(SmartTags("PartNumber"))

Microsoft's official CSV import behavior is documented in the Excel support library; see Export data to Excel (Microsoft Support) for the Access-side equivalent that uses the same delimiter rules.

Solution 2: Direct UNC Write Without Office

WinCC flexible scripting supports UNC paths of the form \\server\share\folder\file.csv directly, but the panel's user context must have write permission on the share. Default panel user is Anonymous; on Windows shares this maps to Everyone:Read by default.

  1. On the file server, create a share (example C:\WinCCProjects as \\FILESERVER\WinCCProjects).
  2. Grant the panel computer account or the Everyone group Change rights (not just Read).
  3. Set NTFS share permissions to Full Control for the share subtree C:\WinCCProjects\Export.
  4. In the panel's Control Panel > Network > User Accounts, optionally enter credentials under Network Identification; on TP1500 Comfort with Windows Embedded Standard 7, configure the credential through Start > Programs > Network > Network ID.
  5. Test with a minimal script that writes a one-line file before running the full export.
Network reachability: The panel and the share host must be on the same broadcast domain, or the gateway must be configured under Control Panel > Network > TCP/IP. Without a gateway, \\10.160.90.109\winccprojects fails with Error 70 (permission denied) or Error 53 (path not found). Verify with ping from Start > Programs > Command Prompt on TP1500 or via ProSave diagnostic terminal.

Solution 3: Using FileCtl.FileSystem on Legacy WinCE Panels

The FileCtl.FileSystem object is the canonical CE-side API in WinCC flexible. It is more reliable on Windows CE 5.0 because it does not depend on the Scripting Runtime being installed separately. The methods differ slightly from FileSystemObject:

FileSystemObject (PC / WES7) FileCtl.FileSystem (WinCE)
CreateTextFile(path, overwrite, unicode) OpenTextFile(path, mode, create) then WriteLine
FolderExists(path) Dir(path) returns path or empty string
CopyFile src, dst FileCopy src, dst (built-in VBScript)
DeleteFile(path) Kill(path) (built-in VBScript)
Sub ExportLegacy(sUncPath, sFileName)
  Dim objFS, objFile
  Dim sPath
  sPath = sUncPath & "\" & sFileName & ".csv"
  
  On Error Resume Next
  Set objFS = CreateObject("FileCtl.FileSystem")
  If Err.Number <> 0 Then
    MsgBox "FileCtl not registered: " & Err.Number
    Exit Sub
  End If
  
  ' FileCtl.FileSystem mode: 1=Read, 2=Write, 8=Append
  Set objFile = objFS.OpenTextFile(sPath, 2, True)
  objFile.WriteLine "Time;Tag1;Tag2"
  objFile.WriteLine Now & ";" & SmartTags("Tag1") & ";" & SmartTags("Tag2")
  objFile.Close
  Set objFile = Nothing
  Set objFS = Nothing
End Sub

The original forum discussion referenced that Scripting.FileSystemObject was not available and FileCtl.FileSystem had to be used. Both objects exist in WinCC flexible 2005 SP1 HF7; however, only FileCtl is guaranteed on every WinCE target. The recommended pattern is the dual-fallback shown in Solution 1.

Solution 4: Round-Trip CSV via Power BI / Excel on the Host

Once the CSV is written to the share, an operator opens it directly in Excel or schedules a Power BI refresh that ingests the file. Microsoft's documented path for ingesting structured CSV into Excel-native visuals is the Data > Get Data > From File > From Text/CSV wizard, which honors the delimiter and encoding chosen on the panel side.

For visualization-only consumption where the user does not need to edit the workbook, Power BI Desktop can be pointed at the same UNC share with a scheduled refresh; details are at Export Data from a Power BI Visualization. This is useful for dashboards that surface the panel's exported tag logs to plant management.

Solution 5: PC-Side Conversion Service (Batch File + Task Scheduler)

When the engineering team requires a true .xlsx file (not a CSV) for compliance reasons, deploy a small scheduled task on the Windows host that monitors the share and converts new CSV files into Excel workbooks through PowerShell + COM:

# Convert-CsvToXlsx.ps1
param([string]$SharePath = "\\FILESERVER\WinCCProjects\Export",
      [string]$DonePath  = "\\FILESERVER\WinCCProjects\Done")

$watcher = New-Object System.IO.FileSystemWatcher $SharePath, "*.csv" -Property @{
  EnableRaisingEvents = $true
  IncludeSubdirectories = $false
}

$action = {
  $path = $Event.SourceEventArgs.FullPath
  Start-Sleep -Seconds 2  # ensure panel has closed the file
  $excel = New-Object -ComObject Excel.Application
  $excel.Visible = $false
  $wb = $excel.Workbooks.Open($path)
  $xlsx = [System.IO.Path]::ChangeExtension($path, ".xlsx")
  $wb.SaveAs($xlsx, 51)  # 51 = xlOpenXMLWorkbook
  $wb.Close($false)
  $excel.Quit()
  [System.Runtime.Interopservices.Marshal]::ReleaseComObject($excel) | Out-Null
  Move-Item $path $DonePath
}

Register-ObjectEvent $watcher "Created" -Action $action
while ($true) { Start-Sleep -Seconds 30 }

Run this on the file server with powershell.exe -ExecutionPolicy Bypass -File Convert-CsvToXlsx.ps1 scheduled at startup under a service account. The panel never sees Excel; it only writes CSV.

Enabling the WinCC flexible Script Debugger

The original poster asked how to read the error text. The WinCC flexible engineering tool ships with a script debugger, but it is disabled by default:

  1. Open WinCC flexible 2005 SP1 HF7 (or matching target version).
  2. Open the project.
  3. From the menu, choose Tools > Settings > Script Editor.
  4. Enable Use Script Debugger. The debugger attaches to the WinCC flexible runtime (PC RT or panel via Ethernet).
  5. Place a breakpoint on the CreateObject line and start the runtime.

For panel-side debugging without the IDE attached, the error-trap pattern shown in the Diagnostic section is more reliable. The debugger requires a working TCP connection to the panel on port 1030 (WinCC flexible debugging port); this is blocked by default on most plant firewalls.

Verifying Network Share Access from the Panel

Before any export script runs, validate that the panel can reach the share. Add a one-shot test script bound to a button:

Sub TestShareAccess()
  Dim objFSO, objFile
  Dim sTestPath
  sTestPath = "\\FILESERVER\WinCCProjects\Export\panel_ping.txt"
  On Error Resume Next
  Set objFSO = CreateObject("FileSystemObject")
  If Err.Number <> 0 Then
    MsgBox "FSO error: " & Err.Description: Exit Sub
  End If
  Set objFile = objFSO.CreateTextFile(sTestPath, True)
  If Err.Number <> 0 Then
    MsgBox "Share access FAILED: " & Err.Number & " " & Err.Description
    Exit Sub
  End If
  objFile.WriteLine "Panel OK at " & Now
  objFile.Close
  MsgBox "Share access OK. Wrote: " & sTestPath
End Sub

Pass criteria: Share access OK dialog appears and a text file with the timestamp is visible at the share root. Failure modes and remedies:

Err.Number Description Root Cause Fix
53 File not found Wrong UNC, host unreachable Verify IP via ping, check subnet/gateway
70 Permission denied Share/NTFS rights Grant Everyone:Change on share, Modify on NTFS
462 Remote server not available Server service stopped or firewall Start lanmanserver, open TCP 445
52 Bad file name or number UNC syntax error, double backslash missing Inspect path string

Migration Path: From WinCC flexible to TIA Portal / WinCC Comfort

Projects originally built in WinCC flexible 2005 SP1 HF7 are migrated to TIA Portal V13 or later using the WinCC Comfort/Advanced converter. The migration preserves VBScripts in most cases, but the Excel restriction is unchanged: TP1500 Comfort and later panels still ship without Office. The migration benefit is improved network stack support (SMB2 / SMB3), better UNC credential management, and the option to use the integrated OPC UA server on the panel (firmware V14 SP1+) for tag export to any OPC UA client, including Excel Power Query.

For deployments that genuinely need Excel automation on the panel host, the only Siemens-supported target is a PC Runtime (WinCC Runtime Advanced or WinCC Professional) running on a full Windows installation. Panels of the TP / MP / KTP / Comfort / Unified families cannot be extended to host Excel.

Troubleshooting Matrix

Symptom Cause Resolution
Error 429 on CreateObject("Excel.Application") Excel COM not on panel Replace with CSV export, see Solution 1 / 2
Error 429 on CreateObject("Scripting.FileSystemObject") Scripting Runtime not on this CE image Use FileCtl.FileSystem instead
Error 70 on UNC write Share rights or panel credentials Grant Change permission, configure panel user
Error 53 on UNC write Host unreachable Verify TCP/IP, gateway, DNS, disable SMB signing on server if needed
File written but appears locked / zero bytes File handle not closed Set objFile = Nothing and call .Close before script ends
CSV opens with all data in column A Wrong delimiter for locale Switch to vbTab or ; depending on Excel locale
Numeric values lose leading zeros Excel auto-formats Prepend ' to force text
Date column shows as text in Excel CSV date format Write ISO 8601 YYYY-MM-DD HH:MM:SS
Script runs on PC RT, fails on TP1500 PC has Office, panel does not Architectural: remove Excel dependency from panel-side script

Verification Checklist Before Handover

  1. Run the TestShareAccess script and confirm a file is written to \\FILESERVER\WinCCProjects\Export.
  2. Open the file from a Windows explorer on a workstation and confirm the Excel text import wizard detects the delimiter.
  3. Trigger the production export from the panel and confirm a CSV file appears within one second of the button press.
  4. Trigger five consecutive exports and verify that file locking does not cause zero-byte output on any.
  5. Power-cycle the panel and re-trigger; the file share must remain reachable.
  6. For each panel in the fleet, repeat steps 1–5 on TP270, MP277, and TP1500 to confirm homogeneous behavior.

FAQ

Why does CreateObject("Excel.Application") fail with Error 429 on my Siemens panel?

The panel firmware (Windows CE 5.0/6.0 or Windows Embedded Standard 7) does not include Microsoft Office or the Excel COM type library. There is no fix on the panel side; remove the Excel dependency and write a CSV file instead, then convert it on a Windows host if a true .xlsx file is required.

Can I install Excel runtime libraries onto a TP270 or MP277?

No. Siemens ships the panel image as a sealed embedded firmware. Adding Office components would violate the Microsoft Office licensing terms and is not supported by Siemens. Use a CSV-based export architecture instead.

Which file system object should I use: FileSystemObject or FileCtl.FileSystem?

Use FileSystemObject (Scripting Runtime) on TP1500 Comfort with Windows Embedded Standard 7 and on all PC Runtime targets. Use FileCtl.FileSystem on legacy Windows CE 5.0 panels (TP270, MP277) where the Scripting Runtime is not registered. The dual-fallback pattern in the article covers both cases.

How do I enable the WinCC flexible script debugger?

In the engineering tool, open Tools > Settings > Script Editor and check Use Script Debugger. The debugger attaches to the runtime over TCP port 1030; ensure the firewall permits this port between the engineering station and the panel.

Why does my VBScript work on PC Runtime but fail on the panel?

PC Runtime runs on a full Windows OS where Excel, Office, and most COM components are registered. The panel image is a locked-down embedded OS without those components. Architect the export so the panel only writes CSV to a network share, and let a Windows host perform any Excel-specific conversion.

Back to blog