A WinCC Professional screen window is not the loaded screen itself. Access the embedded I/O field through the screen window’s Screen property, and do so only after the window is visible. Attempting access while it is invisible can raise Object required: 'screenWindow.Screen'.
Root cause: the embedded screen is unavailable
HMIRuntime.ActiveScreen.ScreenItems("test_settings_window") returns the Screen Window object. Calling ScreenItems directly on that object omits the embedded screen level. The required object path is screenWindow.Screen.ScreenItems("SP_field").
Object availability also depends on execution order. The reported failure occurred when the script tried to resolve screenWindow.Screen while the Screen Window was invisible. Visibility therefore must be established before retrieving the embedded field.
Correct the VBS object path and execution order
Dim data_udt
Dim face_plate
Dim sp_IO_field
data_udt = "changing_pressure_SP_test_DB"
Set face_plate = HMIRuntime.ActiveScreen.ScreenItems("test_settings_window")
If face_plate.Visible = True And face_plate.TagPrefix = data_udt Then
face_plate.Visible = False
Else
face_plate.Visible = False
face_plate.TagPrefix = data_udt
face_plate.CaptionText = data_udt
face_plate.Visible = True
Set sp_IO_field = face_plate.Screen.ScreenItems("SP_field")
sp_IO_field.Unit = SmartTags("unit")
End If
The critical sequence is to assign the UDT prefix, make the Screen Window visible, resolve the loaded screen through .Screen, and then write the I/O field’s Unit property.
Apply and verify the change
- Confirm that
test_settings_windowis the Screen Window name andSP_fieldis the I/O field name inside its loaded screen. - Save and recompile the project.
- Restart the graphics runtime or change screens once so the updated script is loaded.
- Open the faceplate with different UDT data and verify that both the process value and unit change.
Diagnose remaining VBS failures
Add the print job/script diagnose control to the picture and set its property to gsc-diagnose to display VBS errors. Add HMIRuntime.Trace statements before and after the visibility change and object lookup to identify the exact statement that stops execution.
HMIRuntime.Trace "Making screen window visible"
face_plate.Visible = True
HMIRuntime.Trace "Resolving SP_field"
Set sp_IO_field = face_plate.Screen.ScreenItems("SP_field")
HMIRuntime.Trace "SP_field resolved"
FAQ
How do I access an I/O field inside a WinCC Screen Window with VBS?
Resolve the window from the active screen, then use screenWindow.Screen.ScreenItems("SP_field") to access the field inside its loaded screen.
Why does WinCC report Object required: 'screenWindow.Screen'?
The reported error occurs when the script accesses the embedded screen while the Screen Window is invisible. Set Visible = True before resolving the Screen property.
Why does my updated WinCC VBS code not run after editing it?
Save and recompile the project, then restart the graphics runtime or change screens once. Use the print job/script diagnose control with gsc-diagnose and HMIRuntime.Trace to locate any remaining failure.