WinCC Explorer · VBScript · Practical Tutorial

Generate Excel Reports from WinCC Using VBScript

Generate formatted Excel production reports from WinCC tags using VBScript, Excel automation, timestamps and safe object cleanup.

Lab Overview

WinCC VBS Lab 6Estimated time: 90 minutesDifficulty: Intermediate-Advanced

Prerequisites / What You’ll Need

  • Backed-up WinCC Explorer test project
  • Graphics Designer and Global Script VBS access
  • Internal test tags and Runtime diagnostics

Generate Excel Reports from WinCC Using VBScript

This lab targets wincc excel report vbscript with copy-ready examples, expected results and diagnostic guidance.

Safety: Test on internal tags or an approved simulation system. Do not bypass PLC permissives, interlocks, user authorization or plant change control.

1. Choose an Excel Automation Architecture

WinCC VBS can automate desktop Excel through COM when Excel is installed on the Runtime station. For unattended or server systems, CSV or a server-side reporting service is often more reliable. Confirm licensing, interactive-session behavior and support requirements.

2. Create a Workbook and Worksheet

Dim excelApp, workbook, worksheet
Set excelApp = CreateObject("Excel.Application")
excelApp.Visible = False
Set workbook = excelApp.Workbooks.Add
Set worksheet = workbook.Worksheets(1)

worksheet.Name = "Process Report"
worksheet.Cells(1, 1).Value = "Timestamp"
worksheet.Cells(1, 2).Value = "Temperature"
worksheet.Cells(1, 3).Value = "Pressure"

3. Write WinCC Tag Values

Dim tempTag, pressureTag
Set tempTag = HMIRuntime.Tags("Demo_Temperature")
Set pressureTag = HMIRuntime.Tags("Demo_Pressure")
tempTag.Read
pressureTag.Read

worksheet.Cells(2, 1).Value = Now
worksheet.Cells(2, 2).Value = CDbl(tempTag.Value)
worksheet.Cells(2, 3).Value = CDbl(pressureTag.Value)
worksheet.Columns("A:C").AutoFit

4. Save and Clean Up Excel Correctly

Dim reportPath
reportPath = "C:\WinCC_Reports\ProcessReport.xlsx"

workbook.SaveAs reportPath
workbook.Close False
excelApp.Quit

Set worksheet = Nothing
Set workbook = Nothing
Set excelApp = Nothing

Close worksheet/workbook references before quitting Excel. Add scoped error handling and cleanup so a failed save does not leave hidden Excel processes running.

5. Excel Report Troubleshooting

ProblemCheck
Cannot create Excel.ApplicationExcel installation, COM registration, bitness and Runtime identity
Workbook cannot saveFolder access, existing locked file and valid extension
Excel.exe remains runningUnreleased worksheet/range/workbook references or skipped cleanup
Automation fails as a serviceUse CSV or a supported server-side report architecture

Hands-On Verification Lab

Hands-on
1

Prepare a controlled test

Create only the internal tags, folders or disposable database rows required by this tutorial.

The test scope is isolated and documented.
2

Run the smallest example

Execute one operation and inspect WinCC diagnostics before expanding the script.

The expected value, file, object or database result appears once.
3

Test a failure path

Use a safe backup copy to test an invalid tag, path or disposable input.

The script records a useful error and cleans up without an uncontrolled action.

Frequently Asked Questions

Should this WinCC VBScript be tested in production?

No. Use a backed-up training or staging project and follow the plant change-control process.

Which WinCC versions does the example target?

The examples target classic WinCC Explorer V7.x/V8.x. Verify object properties, action signatures and providers in the installed WinCC help.

How should Runtime failures be diagnosed?

Use scoped Err checks, WinCC object diagnostics and HMIRuntime.Trace while recording the exact station, trigger, tag and Runtime identity.

Get the WinCC VB Scripting syllabus

Share your details and a Softwell advisor will contact you with training options.

Build reliable WinCC VBScript projects

Join practical online, classroom or corporate training.

Request Course Details
Verified learning pathway

Discuss WinCC VB Scripting Training

Explore practical WinCC VBS, SCADA, SQL reporting and industrial automation training options.

Content reviewed: 4 August 2026

☎ Call WhatsApp ✉ Email Enquire Now