Executing Picture Navigation via VBScript vs Standard Buttons in WinCC Graphics Designer
To execute picture navigation from a static text or custom graphic in WinCC Graphics Designer using VBScript, assign the target PDL file to the BaseScreenName property for full-screen changes (HMIRuntime.BaseScreenName = "target.pdl"), or assign it to the PictureName property of a specific Picture Window (HMIRuntime.ActiveScreen.ScreenItems("PicWindow").PictureName = "target.pdl"). If the script fails, verify that the Picture Window name exactly matches the object name in the current active screen, ensure the '.pdl' extension is lowercase, and verify that the Picture Window 'Visible' property is set to True. Alternatively, use a standard Windows button with the Dynamic Wizard 'Picture Change' to eliminate script dependencies.
Table of Contents
- WinCC Graphics Architecture: Screen Navigation Fundamentals
- VBScript Object Hierarchy in WinCC Graphics Designer
- Root Causes of Scripted Screen Change Failures
- Step-by-Step VBScript Implementation for Custom Objects
- Standard Button with Dynamic Wizard vs Scripted Navigation
- Verification
- Limitations and Operational Precautions
- Engineer FAQ
- Technical References
- Related Articles
- Related Tags
WinCC Graphics Architecture: Screen Navigation Fundamentals
In SIMATIC PCS 7 OS and WinCC Graphics Designer, process visualization relies on picture files (.pdl). Screen navigation occurs in two distinct operational contexts:
- Full Base Screen Replacement: Replacing the entire process graphic viewport in the runtime workspace (e.g., navigating from Area Overview
@Overview1.pdlto an operational plant graphic likeReactor01.pdl). - Embedded Picture Window Switching: Retaining the master screen layout (such as title bars, alarm lines, and navigation docks) and swapping content inside an embedded picture container (
PictureWindow/ Bildfenster).
Choosing the incorrect object method in VBScript causes runtime navigation commands to fail silently.
VBScript Object Hierarchy in WinCC Graphics Designer
WinCC exposes the HMIRuntime object model to VBScript actions. The primary navigation properties operate as follows:
-
Full Screen Switching:
vbscript HMIRuntime.BaseScreenName = "CC1CC1.pdl"
This directly commands the root WinCC runtime container to loadCC1CC1.pdlinto the primary window. -
Picture Window Switching:
vbscript Sub OnLButtonUp(ByVal Item, ByVal Flags, ByVal x, ByVal y) Dim picWindow Set picWindow = HMIRuntime.ActiveScreen.ScreenItems("PictureWindow1") picWindow.PictureName = "CC1CC1.pdl" picWindow.Visible = True End Sub
Here,PictureWindow1must be the explicitObjectNameproperty of the picture window control residing insideHMIRuntime.ActiveScreen.
Root Causes of Scripted Screen Change Failures
When a VBScript navigation routine fails to switch screens, the fault typically traces to one of four discrepancies:
- Incorrect Object Targeting: In the user's script
HMIRuntime.ActiveScreen.ScreenItems("CC1CC1"),"CC1CC1"was entered as both the control name and the target PDL. If no Picture Window namedCC1CC1exists on the active screen, VBScript generates an unhandled runtime error (Object required: ScreenItems(...)). - Case Sensitivity and Filename Mismatches: WinCC runtime requires precise filename matching. If the file is named
CC1CC1.pdlon disk, referencing"CC1CC1.Pdl"or omitting the.pdlextension on certain WinCC versions causes load failure. - Missing Visibility Activation: If a Picture Window has property
Visible = False, changing thePictureNameproperty loads the file in memory but leaves the container invisible to the operator. - Graphics Cache Lock: If the target
.pdlwas modified and saved without releasing runtime locks, WinCC fails to render the newly requested graphic.
Step-by-Step VBScript Implementation for Custom Objects
Follow this procedure to configure reliable navigation on any static text, polyline, or graphic symbol:
- Verify Object Names in Graphics Designer:
- Open the host screen (e.g.MainView.pdl).
- Click the container Picture Window and open its Properties window.
- Confirm the attributeObject Name(e.g.,pwMainContent). - Configure Static Text Click Event:
- Select the Static Text object.
- In the Properties window, open the Event tab.
- ExpandMouse > Mouse Click(orPress Left).
- Right-click the Action column and select VBS-Action. - Insert Clean Script Code:
vbscript Sub OnClick(ByVal Item) On Error Resume Next Dim picWin Set picWin = ScreenItems("pwMainContent") If Not picWin Is Nothing Then picWin.PictureName = "CC1CC1.pdl" picWin.Visible = True End If End Sub - Save and Test: Save the picture and launch OS Runtime to verify.
Standard Button with Dynamic Wizard vs Scripted Navigation
The table below contrasts standard button wizard configuration with custom VBScript navigation:
Verification
Confirm that screen navigation operates reliably in runtime:
- Open WinCC Explorer, activate OS Runtime, and navigate to the screen containing the static text.
- Open the WinCC GSC Diagnostics window (or launch
apdiag.exe/ Output Window for VBScript errors). - Click the static text object.
- Confirm that the target screen
CC1CC1.pdlloads immediately inside the picture window or main screen. - Verify that no VBScript runtime errors appear in the GSC Diagnostics window.
Limitations and Operational Precautions
Review the following technical limitations when implementing custom navigation scripts:
- Bypassing PCS 7 Picture Tree: Hardcoded screen changes bypass the PCS 7 standard Area Overview and Picture Tree Manager. When arbitrary screens are opened, the
@Overview1navigation bar may lose synchronization with the current plant area. - VBScript Single-Threaded Execution: In WinCC, VBScript executes on a single global thread per client session. Long-running loops or complex queries inside button clicks can freeze graphic responsiveness.
- Case Sensitivity: Always ensure consistent lower-case
.pdlextensions across scripts and file names on disk.
Engineer FAQ
Why use HMIRuntime.BaseScreenName instead of ScreenItems for full-screen changes?
HMIRuntime.BaseScreenName targets the top-level runtime container, replacing the entire root graphic. ScreenItems only targets child controls embedded within the currently open screen.
Can a standard button change pictures without any VBScript or C-code?
Yes. By dropping a standard Windows button onto the screen and running the Dynamic Wizard 'Picture Change' (Bildwechsel), WinCC automatically attaches pre-compiled C-code without requiring manual programming.
Where can I see VBScript runtime errors when a navigation click fails?
Insert an 'Application Window' control configured for 'Global Script Diagnostics' (GSC Diagnostics) onto a test screen, or launch the Siemens APDiag utility (apdiag.exe) from the WinCC bin folder.
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 Dynamic Wizard and Standard Objects Documentation: https://support.industry.siemens.com/cs/ww/en/view/109763784
Related Articles
- Harmonizing Multiproject Languages and Text Libraries in SIMATIC Manager and WinCC OS
- Resolving SFC Faceplate Header Truncation and Clipping via Windows DPI Scaling
- Troubleshooting 'New Project Wizard' Failures to Launch in SIMATIC PCS 7
Related Tags
- WinCC Graphics Designer
- VBScript Navigation
- Picture Window
- Dynamic Wizard
- BaseScreenName
- PCS 7 OS