How to Read and Write Siemens WinCC SCADA Tag Values in Microsoft Excel Using VBScript

Published on Jun17, 2025 | Category: wincc
Share this article:

Reading and writing Siemens WinCC SCADA tag values to and from Microsoft Excel using VBScript is a powerful method for integrating industrial automation systems with user-friendly reporting and logging tools. This technique enables SCADA engineers and system integrators to automate data exchange between the WinCC runtime environment and Excel spreadsheets without requiring additional software or OPC configurations.
In Siemens WinCC, each tag represents a variable linked to a sensor, actuator, or process value. With VBScript—natively supported in WinCC—you can access these tags, retrieve real-time values, and write them directly into Excel files for storage, analysis, or auditing purposes. Conversely, you can also read data from Excel and push it back into SCADA tags for setpoints, parameters, or simulation inputs. in this article we see how to

VBScript interacts with Excel via COM automation using CreateObject('Excel.Application'). Tags are accessed in WinCC using HmiRuntime.Tags('TagName'), and values can be read using .Read or written using .Write. Scripts can be triggered by button clicks, cyclic events, or runtime conditions.

Create and Log Siemens WinCC SCADA Tag Values to Excel Using VBScript

This VBScript solution for Siemens WinCC SCADA enables automatic creation of an Excel file and real-time logging of multiple tag values along with timestamps. The script simplifies historical data logging by eliminating the need for manual Excel setup or third-party software integration.

Upon execution, the script checks whether the specified Excel log file (e.g., D:\Report\TagLog.xlsx) exists. If not, it automatically creates the file, inserts a header row with tag names, and then starts appending runtime tag values to it. Each log entry includes the current date and time, making it ideal for time-based data tracking and diagnostics.

The VBScript uses native WinCC functions such as HmiRuntime.Tags("TagName").Read to access SCADA tag values and writes the data into Excel via COM automation using CreateObject("Excel.Application"). The script is designed to be triggered from a button click, event, or cyclic execution within WinCC Runtime.

Key Features:

This script is especially useful for engineers and system integrators who want to track tag histories, capture operator data, or maintain audit trails without using external data loggers or SCADA historian systems.

Whether you're monitoring alarms, analog values, or digital inputs, this approach provides a flexible, Excel-based logging mechanism directly from WinCC Runtime using VBScript.

WinCC SCADA Excel Data Logging VBScript Script Layout Overview

To create the logging script in Siemens WinCC, open the Global Script editor, double-click on VBScript, and add a new module. Then paste the following script into the module to enable automatic Excel file creation and tag value logging.

img/wincc-excel-datalog-vbscript/wincc-vbscript-example-to-log-data-in-excel.webp

Add Tags to Log Data in Excel

To enable Excel logging in Siemens WinCC, open the Tag Management section and create the required tags with appropriate data types such as Real, Integer, or Bool. These tags will be referenced in the VBScript to log values in the Excel sheet during runtime.

img/wincc-excel-datalog-vbscript/wincc-scada-tag-management-for-logging.webp

Create a Screen and Add Items to Log Data in WinCC

To build the data logging interface in Siemens WinCC, open the Graphics Designer and create a new screen. Add two Input/Output Fields and assign appropriate tags to each field (these will be the tags you want to log).

Next, insert a Button onto the screen and rename it to "Data Log". This button will trigger the VBScript to log the tag values into an Excel file automatically.

Select the button, go to the Properties window, and under Events > Mouse Click, add a VBScript action that calls your logging function.

img/wincc-excel-datalog-vbscript/wincc-scada-datalog-screen-button-event.webp

Call VBScript to Log Data

To enable logging, enter the following VBScript under the Mouse Click event of the "Data Log" button. This script will trigger the logging function and write the current tag values into the Excel file.


Sub OnClick(Byval Item)         
Dim selectedTags
    ' Add more tags if needed
    selectedTags = Array("reprot_tag_1", "report_tag_2", "report_tag_3")
    Call LogTagsToExcel(selectedTags)
End Sub

Save, Compile, and Test the Program

Now that your VBScript and screen elements are configured, follow these steps to complete the setup:

img/wincc-excel-datalog-vbscript/wincc-scada-save-compile-test.webp