Resolving WinCC VBS Alarm Acknowledgment Type Mismatch Error

David Krause11 min read
SiemensTroubleshootingWinCC
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

Problem Overview

Engineers maintaining or upgrading legacy WinCC HMI projects routinely encounter a Type mismatch runtime error when they attempt to acknowledge an alarm from a button's VBScript action. The call most frequently associated with the failure is:

Sub acknowledgeAlarms
    Dim returnValue
    returnValue = AXC_OnBtnVisibleAck("mainpage.pdl","alarmControl")
End Sub

The error fires immediately because the developer is invoking a function exported by the WinCC C API (AXC_OnBtnVisibleAck) inside a VBScript routine. The WinCC runtime binds the call to the VBS interpreter, cannot resolve the symbol, and aborts the script with an automation type mismatch. The alarm remains in the unacknowledged state and the button becomes effectively non-functional.

The same symptom also appears when engineers try to call any of the AXC_* or other documented C functions from a button's VBS action, or when they wrap a C function inside a VBS trigger expecting mixed-mode execution. Because the two scripting runtimes are not inter-operable, the only reliable path is to use the API exposed for the runtime that the script is actually written in.

Root Cause Analysis: The C / VBScript Boundary

WinCC supports two parallel scripting environments inside the Graphics Designer:

  • C scripting — ANSI-C with WinCC-specific header includes such as apdefap.h, apbrowse.h, and the AXC_* alarm/messaging wrappers in apmdefap.h.
  • VBScript — Microsoft VBScript running against the WinCC object model exposed through HMIRuntime.

The two runtimes are strictly isolated. A function compiled into the C runtime cannot be invoked from VBS and vice versa. The compiler and the runtime resolver keep separate symbol tables, and there is no built-in marshalling layer between them.

Critical: The AXC_OnBtnVisibleAck family of functions are C-API calls declared in the WinCC C header set. They are not exposed to the VBS object model. Any attempt to invoke them from Sub ... End Sub in a button's VBS event results in a Type Mismatch error at the first line.

Two further constraints compound the issue in WinCC V6 and early V7 projects:

  1. VBS in those versions cannot directly acknowledge an alarm — it can read the alarm object, change its State field, append a comment, or create a new alarm, but the runtime does not expose a method that toggles the operator acknowledgment flag in the same way the C alarm viewer does.
  2. Documentation shipped with these versions is inconsistent about this limitation, and V6 example projects frequently contain the same misuse pattern, encouraging copy-paste errors.

Affected Versions and Components

WinCC Version VBS Acknowledge C AXC_OnBtnVisibleAck Recommended Path
WinCC V6.0 / V6.2 Not exposed for ack Available C action on a separate button, or Script Connector
WinCC V7.0 / V7.2 Limited (state/comment write) Available HMIRuntime.Alarms Write API + C for ack
WinCC V7.3 / V7.4 / V7.5 Write API stable Available Use WinCC AlarmControl "Single acknowledge" or VBS Write API
WinCC Unified (TIA Portal V17+) System function AcknowledgeAlarm N/A (Unified uses RT scripting) HMIRuntime.Alarms.Acknowledge or system function

Solution Path 1 — Use the Built-In Alarm Control Buttons

The simplest and most defensible solution in every WinCC runtime is to delegate acknowledgment to the AlarmControl's built-in buttons rather than to a custom VBS button. Siemens documents three standard acknowledgment operators:

  1. Single acknowledgment — acknowledges the highlighted single message.
  2. Group acknowledgment — acknowledges all currently visible/selected messages in the active list view.
  3. Always-acknowledge (operator stationary) — acknowledges based on operator workstation regardless of which screen the message originates from.

Details on the three options (single acknowledgment, group acknowledgment, and the operator-station mode) are documented in Siemens Support Entry ID 7797013 — "How do you acknowledge alarm messages in WinCC?".

Implementation steps:

  1. Open the WinCC Explorer project and open the Graphics Designer.
  2. Insert a WinCC AlarmControl on the picture (e.g., mainpage.pdl).
  3. In the AlarmControl Configuration Dialog, enable the toolbar elements Single acknowledgment and Group acknowledgment.
  4. Optionally lock the toolbar (Operator authorization) so that ack authority is governed by user rights.
  5. Select the row in the running view and click the toolbar button. The runtime sets the State bit hmiAlarmStateAcknowledged in the alarm record.
Use this path wherever the project allows it. It eliminates the cross-runtime call, removes the custom script entirely, and survives WinCC service packs because the AlarmControl's button handling is maintained by Siemens, not by project code.

Solution Path 2 — VBScript With the HMIRuntime Write API

For projects that require a VBS-driven custom button (for example, a faceplate that lives outside the AlarmControl), the VBS object model exposes the alarm object and allows state/comment writes. The acknowledgment bit itself is restricted to the runtime; what VBS can do is modify the State and Comment fields, then trigger a follow-on alarm that has the desired "come + comment" semantics. The canonical example pattern is:

Sub OnClick(ByVal Item)
    Dim MyAlarm
    Set MyAlarm = HMIRuntime.Alarms(1)
    MyAlarm.State = 5         ' hmiAlarmStateCome + hmiAlarmStateComment
    MyAlarm.Comment = "MyComment"
    MyAlarm.UserName = "Hans-Peter"
    MyAlarm.ProcessValues(1) = "Process Value 1"
    MyAlarm.ProcessValues(4) = "Process Value 4"
    MyAlarm.Create "MyApplication"
End Sub

Field reference for this template:

Property / Call Type Purpose
HMIRuntime.Alarms(Index | Name) Returns HMIAlarm object Bind to an existing message or to a class
MyAlarm.State Long — bitwise combination 1 = Come, 2 = Go, 4 = Comment, 8 = Ack (constants exposed by WinCC)
MyAlarm.Comment String Operator-supplied comment text, max 255 chars
MyAlarm.UserName String Operator name logged with the entry
MyAlarm.ProcessValues(n) Variant Associated process value 1..10 (WinCC message configuration dependent)
MyAlarm.Create Method Triggers the alarm instance to be written to the message archive

The State = 5 line is a bitwise OR of 1 (Come) plus 4 (Comment). This is what produces the comment-annotated trigger entry you see in the archived message list. It does not toggle the acknowledgment state of a previous message; for that you must use Path 1, Path 3, or Path 4 below.

Solution Path 3 — Call the C Function From a C Action (Not VBS)

If the application logic requires the exact AXC_OnBtnVisibleAck semantics (visible-ack on a specific picture and AlarmControl), move the call into a C action on the same button. The legacy pattern looks like this:

// C action placed on the button's "Click" event
#include "apdefap.h"

void OnClick(char* lpszPictureName, char* lpszObjectName)
{
    AXC_OnBtnVisibleAck("mainpage.pdl", "alarmControl");
}

Procedure:

  1. Open the button's Properties > Events > Click.
  2. Select C action (not VBScript).
  3. Paste the function above, adjusting the project path and control name to match your picture.
  4. Recompile and download the runtime.
Do not keep both a VBS and a C action on the same click event; the runtime executes whichever was registered last and the behavior becomes load-order dependent.

Solution Path 4 — WinCC Unified AcknowledgeAlarm

If the project is being modernized to WinCC Unified (TIA Portal V17 and newer), the runtime exposes a proper acknowledgment system function. Reference: TIA Portal Docs — WinCC Unified / AcknowledgeAlarm.

The system function can be called from a button's OnClick event. The configuration in the Unified Engineering is:

  1. Open the HMI screen and select the button.
  2. In the Properties > Events > Click handler, choose Add new function.
  3. Pick AcknowledgeAlarm from the system function list.
  4. Bind the parameters to a configured alarm instance, typically the active logging tag or the alarm name returned by the screen context.
  5. Compile and test.

For Unified scripting, the equivalent JavaScript / C# call inside a global module is:

// JavaScript in a WinCC Unified button or scheduled task
import { HMIRuntime } from "HMIRuntime";
await HMIRuntime.Alarms.AcknowledgeAsync(alarmName, { userName: "Operator", comment: "Ack from script" });

Unified doesn't expose the obsolete AXC_* set, so cross-runtime confusion is removed entirely. New projects should target Unified where the runtime supports it.

Solution Path 5 — WinCC Script Connector (Legacy Bridge)

The WinCC Script Connector, distributed by the Siemens WinCC Competence Center Mannheim, is a free add-on that bridges C and VBS functions through a registration layer. When loaded, the connector surfaces a small set of C-side alarm helpers as registered Automation objects callable from VBS, including wrappers for the visible-ack buttons.

Practical caveats:

  • It is a third-party (CC-Mannheim) tool, not part of the WinCC installation media.
  • It must be installed on the engineering station and on every runtime station that needs the bridge.
  • It is not guaranteed to remain compatible after major WinCC service packs; pin the WinCC version on every station before upgrading.
  • The connector adds DLL load time at startup; budget an additional 1–2 s for HMI boot.

Use the connector as a stop-gap on legacy projects where restructuring to Solution Path 2 or 4 is blocked by certification or copy-paste-exact requirements.

Comparison: Which Path To Choose

Criterion Path 1 (AlarmControl button) Path 2 (VBS Write API) Path 3 (C action) Path 4 (Unified Ack) Path 5 (Script Connector)
WinCC V6 / V7 Yes Limited Yes No Yes
WinCC V7.3+ Yes Yes Yes No Yes
WinCC Unified Yes No (different API) No Yes (recommended) No
Custom button faceplate No Yes Yes Yes Yes
Custom comment / process values Limited Yes No Yes Partial
Long-term Siemens support Full Full Full Full Best-effort
Migration cost Low Low Low High Low

Verification Steps

Regardless of which path you choose, validate it with the following sequence:

  1. Compile clean. In the Graphics Designer, request a "Recompile all". C actions that reference unknown APIs (e.g., a typo'd AXC_OnBtnVisibleAck when the project is missing a required alarm optional package) will surface compile errors before download. VBS uses late binding, so errors only show at runtime.
  2. Trigger a real alarm. Force a process value that drives a configured message priority class to the alarm-state threshold.
  3. Watch the message frame. In the AlarmControl, the message must show the acknowledgment icon, the operator timestamp, and the comment text (where applicable).
  4. Inspect the archive. Open WinCC TagLogging or the SQL archive view and confirm the StateChange row carries the new acknowledgment bit and the correct UserName.
  5. Audit log. Verify in the alarm audit that the entry is attributed to the logged-in user, not to SYSTEM.
  6. Operator-rights test. Log in as a non-privileged user and verify the button is disabled or hidden per the configured authorization level.

Troubleshooting Matrix

Symptom Likely Cause Fix
Type mismatch in VBS at AXC_OnBtnVisibleAck(...) C function called from VBS Move to C action (Path 3) or remove call (Path 1 / 2)
HMIRuntime.Alarms(1) returns Nothing Index out of range, or alarm class not loaded Iterate with For Each; confirm the alarm class is compiled into the picture
Comment text missing in archive State bit for Comment (4) not set Use State = 5 (Come + Comment) or 13 (Come + Comment + Ack) and re-call Create
C script "undefined symbol" on build Missing #include "apdefap.h" Add the include and the alarm wrapper header
Alarm button disabled at runtime Operator authorization level too low Raise the level in User Administrator; re-download the runtime
Acknowledge works on engineering station but not on runtime client Server project not fully downloaded, alarm mirror out of sync Re-copy OS, re-initialize alarm mirror, restart WinCC Runtime
Unified: AcknowledgeAlarm not in the function list Library version of TIA portal below V17 Upgrade the engineering portal to V17+ and re-import the HMI device
VBS error 800A000D "Type mismatch" on HMIRuntime.Alarms(...).State = 5 Alarm object is read-only on the runtime (cannot change state of an instance that already came and went) Write a new instance with the correct state instead of mutating an existing one

Engineering Recommendations

  • Treat the C / VBS boundary as a hard architectural line and document it in your project programming guideline. New work should stay on VBS or move entirely to Unified, not both.
  • Avoid the AXC_* family for new code; even on C actions, prefer the WinCC AlarmControl's internal acknowledgment API and surface that through a single, reviewed C function module.
  • If a custom faceplate must trigger acknowledgment, build a small wrapper library of C functions and a parallel set of VBS stubs that perform the equivalent operation through legitimate channels; never let ad-hoc calls leak across the boundary.
  • For TIA Portal migration projects, prefer WinCC Unified's native AcknowledgeAlarm system function. Reference: WinCC Unified — AcknowledgeAlarm.
  • Add the Siemens Support article ID 7797013 to your team's bookmarked reference set. It is the canonical Siemens answer to "how do I acknowledge?" and is updated with each service pack.

Why does WinCC throw "Type mismatch" on AXC_OnBtnVisibleAck from VBS?

AXC_OnBtnVisibleAck is a C-API function declared in the WinCC C header set. WinCC keeps separate symbol tables for C and VBS runtimes; a VBS button has no visibility into C symbols and reports a Type Mismatch at the first VBS line that tries to resolve the call. Move the invocation into a C action on the same button or use the AlarmControl's built-in acknowledgment toolbar.

Can I acknowledge alarms with VBS in WinCC V6 or V7?

Direct acknowledgment is not exposed to the VBS model in V6 or early V7. VBS can read or write HMIRuntime.Alarms(Index), set State bits (1=Came, 2=Went, 4=Comment), and call Create, but toggling the acknowledged bit on an existing message requires the AlarmControl button or a C action. WinCC Unified (TIA Portal V17+) provides AcknowledgeAlarm as a proper system function.

What does the State value 5 mean in the WinCC alarm object?

5 is the bitwise OR of hmiAlarmStateCome = 1 and hmiAlarmStateComment = 4. Writing MyAlarm.State = 5 tags the new alarm instance as having both "Came" status and an operator comment. To include acknowledgment at the same time use the bitwise OR that includes the Acknowledge bit (typically 8, giving 13 for Come + Comment + Ack).

Is WinCC Script Connector supported by Siemens?

The WinCC Script Connector is distributed by the Siemens WinCC Competence Center Mannheim as a free add-on, not by the main WinCC product line. It is functional but receives best-effort maintenance and may not survive every major WinCC service pack unchanged. For new projects, prefer stock AlarmControl buttons or migration to WinCC Unified.

Which approach works in WinCC Unified?

WinCC Unified exposes a system function called AcknowledgeAlarm that you can wire to a button's Click event in the TIA Portal screen editor. The legacy AXC_* symbols do not exist in Unified. Scripted acknowledgment in Unified uses HMIRuntime.Alarms.Acknowledge(alarmName) from JavaScript or C#. See the Unified AcknowledgeAlarm documentation for parameter binding details.

Back to blog