How to Read, Write, and Print Siemens WinCC SCADA Data Logs to Excel using VBScript

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

Integrating Siemens WinCC SCADA with Microsoft Excel using VBScript enables powerful automation for real-time data handling, historical logging, and report generation. This functionality is essential for engineers and system integrators who need to streamline SCADA data analysis, simplify recordkeeping, or generate formatted print reports without manual intervention.
In this comprehensive guide, you'll learn how to read tag values from WinCC, write data into Excel workbooks, and print log reports directly from Excel using VBScript scripts executed within the SCADA environment. These scripts can be triggered on events such as button clicks or timed intervals, making them ideal for daily log creation or shift-based reporting. in this article We'll cover:


By the end of this tutorial, you’ll be able to create a fully automated data flow from Siemens WinCC to Excel, reducing human error, saving time, and enhancing report accuracy for industrial operations. This is particularly useful for industries like manufacturing, energy, and process control where data tracking is critical.

WinCC Tag to Read and Write from Excel

Open Tag Management and insert the tags report_tag_1, report_tag_2, and report_tag_3. Use the Floating data type as shown below.

img/wincc-read-write-excel/wincc-tag-to-read-and-write-from-excel.webp

WinCC SCADA Screen Component to Read, Write, and Log Data in Excel

Open the Graphics Designer in Siemens WinCC and design your SCADA screen for Excel data interaction. Add three Input/Output field elements and assign the tags report_tag_1, report_tag_2, and report_tag_3 which were previously created in Tag Management. These fields will be used to display live data from the SCADA system and allow operators to input values if needed.

Next, add three functional buttons to the screen interface:

You can use VBScript on each button’s click event to implement the respective logic for Excel automation. This setup enhances SCADA usability, allowing both monitoring and reporting from a single screen.

img/wincc-read-write-excel/wincc-scada-screen-component-to-read-write-and-log-data-in-excel.webp

WinCC SCADA VBScript to Write Tag Values in Excel

To enable automatic logging of SCADA tag values into Excel, open the Global VBScript Editor in Siemens WinCC. Create a new script or edit an existing one, and insert the following VBScript code. This script writes the values of report_tag_1, report_tag_2, and report_tag_3 into a specified Excel file. If the Excel file does not exist at the specified path, the script will automatically create it and then log the tag data into the next available row.

Before using this script in runtime, ensure that:

Once verified, save the script and assign it to the desired button or event on the SCADA screen to start logging data directly into Excel with a single click.

img/wincc-read-write-excel/wincc-scada-vbscript-to-write-tag-values-in-excel.webp

WinCC SCADA VBScript to Read Tag Values from Excel

To retrieve data from an Excel file and populate SCADA tags in Siemens WinCC, open the Global VBScript Editor and add the script shown below. This VBScript reads values from a specific row and column in an existing Excel sheet and assigns them to the tags report_tag_1, report_tag_2, and report_tag_3.

Before using this script, make sure that:

After adding the script, perform a syntax check to ensure there are no errors, and then bind the script to the “Read” button on your SCADA screen. This setup allows operators to import previously logged or manually entered Excel data directly into the SCADA runtime environment.

img/wincc-read-write-excel/wincc-scada-vbscript-to-read-tag-values-from-excel.webp

WinCC SCADA VBScript to Export Excel Sheet as PDF

To automate PDF report generation from Siemens WinCC SCADA, use VBScript within the Global Script Editor. The VBScript below opens an existing Excel file, defines a print area, and silently exports the content as a PDF file to a predefined path. This method does not use a print dialog and relies on Excel’s built-in PDF export functionality (Excel 2007 or later).

Before executing the script, ensure the following prerequisites are met:

Once verified, assign this script to a WinCC screen button such as "Export to PDF". With one click, operators can generate a shift report, production summary, or historical data log in PDF format for easy printing or sharing.

img/wincc-read-write-excel/wincc-scada-vbscript-to-print-excel-sheet-as-pdf.webp

WinCC SCADA Read Tag Value from Screen Component

Open Graphics Designer and open the same screen created earlier with the input/output fields and control buttons. Select the Read button on the screen, and in the Properties window, go to the Events tab.

Choose the Mouse Click event and assign a C Action. In the script area, call the global VBScript subroutine that you created for reading Excel data into WinCC tags. Example:


Call ReadTagValuesFromExcel()

This ensures that when the operator clicks the "Read" button on the screen, the SCADA system will automatically open the Excel file, read the tag values from predefined cells, and update the associated screen tags accordingly.


WinCC SCADA Write Tag Value from Screen Component

In the Graphics Designer, locate the same SCADA screen and select the Write button. Navigate to the Events tab in the properties pane, then choose the Mouse Click event.

Add a C Action that calls the global script for writing tag values to Excel:


Call WriteTagValuesToExcel()

When this button is clicked during runtime, the script writes the current values of the SCADA screen tags to the Excel file specified in the script. This can be useful for logging operator input, setpoints, or manual entries into a structured report.


WinCC SCADA Export to PDF from Screen Component

To allow operators to generate PDF reports directly from the SCADA screen, select the Print or Export to PDF button in Graphics Designer. Under the Events tab, select the Mouse Click event and add a C Action.

Use the following script call to run the global subroutine that exports the Excel log to a PDF file:


Call ExportExcelSheetAsPDF()

This will trigger the VBScript that opens the Excel file, defines the print area, and exports it to a predefined PDF path without any user interaction. It’s ideal for shift-wise reports or audit-ready logs.


Test WinCC SCADA Runtime Script: Read, Write, and Export to PDF

To verify the full integration of WinCC SCADA with Excel using VBScript, test each button during runtime using the following file paths:


🔵 Read Button — Call ReadTagValuesFromExcel()

This button loads tag values from Excel into the SCADA screen. At runtime:


🟠 Write Button — Call WriteTagValuesToExcel()

This button saves current WinCC tag values into Excel. To test:


🟢 Export to PDF Button — Call ExportExcelSheetAsPDF()

This button exports the Excel file to a PDF format without opening any dialog box. To test:

If the PDF doesn't appear, ensure Microsoft Excel 2007 or later is installed and the path exists. Also confirm no Excel process is left running in the background.

img/wincc-read-write-excel/test-wincc-scada-runtime-script-read-write-export.webp