Referencing Nested Picture Windows Across Hierarchy Levels in WinCC VBScript
To reference an object located inside deeply nested Picture Windows in SIMATIC PCS 7 OS using VBScript where HMIRuntime.ActiveScreen fails, address the control through the HMIRuntime.Screens hierarchical path syntax. In WinCC, nested picture windows are traversed using the syntax: HMIRuntime.Screens("RootScreen.Window1:ChildPic1.Window2:ChildPic2").ScreenItems("TargetObject"). For a control named 'PIC_HoraHora_1' residing in @logo.pdl inside picture window 'picturewindow1' of 'overview1.pdl' under root '@SCREEN', reference it via: HMIRuntime.Screens("@SCREEN.@win11:overview1.picturewindow1:@logo").ScreenItems("PIC_HoraHora_1").
Table of Contents
- WinCC Graphics Object Hierarchy and Picture Window Nesting
- Why HMIRuntime.ActiveScreen Fails Across Nested Windows
- Syntax Rules for HMIRuntime.Screens Addressing
- Step-by-Step VBScript Implementation for CSV Trend Export
- Addressing Syntax Comparison Across WinCC Scenarios
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
WinCC Graphics Object Hierarchy and Picture Window Nesting
In SIMATIC PCS 7 OS, the runtime visualization architecture organizes user screens inside hierarchical containers called Picture Windows (Bildfenster). The root container is @SCREEN.pdl, which hosts navigation banners, alarm headers, and the working area.
WinCC supports nesting Picture Windows up to 8 hierarchy levels deep. When a control (such as a WinCC TrendControl, AlarmControl, or gauge) is embedded inside a sub-picture (e.g. @logo.pdl), the control is encapsulated within the scope of its immediate parent container rather than the global desktop screen.
Why HMIRuntime.ActiveScreen Fails Across Nested Windows
Engineers developing automation scripts often employ HMIRuntime.ActiveScreen.ScreenItems("ObjectName"):
HMIRuntime.ActiveScreenresolves strictly to the picture file that currently holds desktop keyboard/mouse focus.- If a script executes from a button on
@Overview1.pdlor a global action,ActiveScreenpoints tooverview1.pdl. - Because the target TrendControl (
PIC_HoraHora_1) resides inside@logo.pdl, the graphics engine cannot locate the object withinoverview1.pdl, generating a VBScript runtime exception (Object required: ScreenItems(...)).
Syntax Rules for HMIRuntime.Screens Addressing
WinCC requires a precise composite path string to navigate nested container boundaries:
- Root Screen: Specify the root screen name without file extension (
@SCREEN). - Dot Separator (
.): Appends the first Picture Window object name (.@win11). - Colon Separator (
:): Appends the name of the picture currently loaded inside that window (:overview1). - Recursive Child Windows: For each subsequent child window, append
.ChildWindow:ChildPicture. - ScreenItems Binding: Once the path to the target picture is fully resolved, call
.ScreenItems("TargetObject").
Step-by-Step VBScript Implementation for CSV Trend Export
Follow this sample code to manipulate the trend control and trigger a CSV export from a top-level action:
Sub ExportTrendData()
On Error Resume Next
Dim objScreen, objTrend, startTime, endTime
' Resolve the nested path to @logo.pdl
Set objScreen = HMIRuntime.Screens("@SCREEN.@win11:overview1.picturewindow1:@logo")
If objScreen Is Nothing Then
HMIRuntime.Trace "Error: Unable to locate target screen hierarchy." & vbCrLf
Exit Sub
End If
Set objTrend = objScreen.ScreenItems("PIC_HoraHora_1")
If Not objTrend Is Nothing Then
startTime = DateAdd("n", -10, Now())
endTime = Now()
objTrend.TimeAxisRangeType = 1
objTrend.Online = False
objTrend.TimeAxisBeginTime = startTime
objTrend.TimeAxisEndTime = endTime
objTrend.Activate
' Execute CSV export method
objTrend.Export "C:\Export\TrendData.csv"
End If
End Sub
Addressing Syntax Comparison Across WinCC Scenarios
The table below details addressing syntax across different scripting contexts:
ScreenItems("PIC_HoraHora_1")@logo.pdl itselfScreenItems("picturewindow1").Screen.ScreenItems(...)overview1.pdlHMIRuntime.Screens("@SCREEN.@win11:overview1.picturewindow1:@logo")Item.Parent.Parent.ScreenItems(...)HMIRuntime.BaseScreenName = "NewPage.pdl"Verification
Verify script execution and object referencing in runtime:
- Open WinCC GSC Diagnostics (
apdiag.exe/ Application Window for Global Script Diagnostics). - Trigger the VBScript action from the operator interface.
- Verify that no VBScript runtime errors (e.g. error code
800A01A8Object Required) appear in the diagnostics window. - Check the file system; confirm the CSV export file is successfully generated with valid timestamped trend records.
- Verify that the trend control in
@logo.pdlreflects the modified time axis boundaries.
Limitations and Operational Precautions
Observe the following safeguards when scripting nested picture windows:
- Omit the .pdl Extension in Path Strings: In
HMIRuntime.Screens, specify picture names without the.pdlextension (e.g.:overview1, not:overview1.pdl), as adding the extension causes path parsing failure. - Exact Casing Mandatory: WinCC internal string comparisons for picture windows and objects are case-sensitive. Ensure object names match Graphics Designer properties exactly.
- Asynchronous Timing: If the target picture window is not loaded or has
Visible = False, object referencing may fail; always includeIf Not objTrend Is Nothingerror handling.
Engineer FAQ
Why must the .pdl extension be omitted in the HMIRuntime.Screens path string?
WinCC internal object model parses the picture name token up to the colon delimiter and automatically binds the picture database handle. Appending '.pdl' within the path causes string comparison mismatch.
Can I address an object inside a Picture Window if the window is currently invisible?
Yes, as long as the Picture Window has a picture assigned to its PictureName property and is loaded in runtime memory, VBScript can read and write its properties even if Visible = False.
What is the maximum nesting depth for Picture Windows in WinCC?
SIMATIC WinCC supports a maximum nesting depth of 8 levels of Picture Windows.
Technical References
- SIMATIC WinCC V7.4 Scripting - VBS, ANSI-C, VBA Manual: https://support.industry.siemens.com/cs/ww/en/view/102601737
- SIMATIC PCS 7 OS Graphics Configuration Guide: https://support.industry.siemens.com/cs/ww/en/view/109780765
- WinCC V7.4 TrendControl and AlarmControl Programming Reference: https://support.industry.siemens.com/cs/ww/en/view/109763784
Related Articles
- Executing Picture Navigation via VBScript vs Standard Buttons in WinCC Graphics Designer
- Resolving SFC Faceplate Header Truncation and Clipping via Windows DPI Scaling
- Harmonizing Multiproject Languages and Text Libraries in SIMATIC Manager and WinCC OS
Related Tags
- WinCC VBScript
- Picture Window
- HMIRuntime.Screens
- TrendControl Export
- PCS 7 Graphics
- ScreenItems